haskell / haskell/cabal

Even after setting PKG_CONFIG_PATH, cabal requires --extra-lib-dirs

Open
#5,841 2 comments 0 reactions 0 assignees View on GitHub
blocked: info-needed re: pkg-config
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

When trying to build [xmobar](https://hub.darcs.net/vmchale/xmobar-vanessa/), I run into the following:

```
PKG_CONFIG_PATH=/home/vanessa/.cpkg/libXft-2.3.2-469cf1f92ca0db34/lib/pkgconfig cabal new-build
```

fails with

```
Resolving dependencies...
Build profile: -w ghc-8.6.3 -O1
In order, the following will be built (use -v for more details):
- xmobar-vanessa-0.1.0.0 (exe:xmobar) (first run)
Configuring executable 'xmobar' for xmobar-vanessa-0.1.0.0..
Preprocessing executable 'xmobar' for xmobar-vanessa-0.1.0.0..
Building executable 'xmobar' for xmobar-vanessa-0.1.0.0..
[1 of 1] Compiling Main ( app/Main.hs, /home/vanessa/programming/haskell/done/xmobar-vanessa/dist-newstyle/build/x86_64-linux/ghc-8.6.3/xmobar-vanessa-0.1.0.0/x/xmobar/build/xmobar/xmobar-tmp/Main.o )
Linking /home/vanessa/programming/haskell/done/xmobar-vanessa/dist-newstyle/build/x86_64-linux/ghc-8.6.3/xmobar-vanessa-0.1.0.0/x/xmobar/build/xmobar/xmobar ...
/usr/bin/ld.gold: error: cannot find -lXft
/home/vanessa/.cabal/store/ghc-8.6.3/xmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3/lib/libHSxmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3.a(Text.o):s3dGD_info: error: undefined reference to 'XftFontClose'
/home/vanessa/.cabal/store/ghc-8.6.3/xmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3/lib/libHSxmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3.a(MinXft.o):r30wJ_info: error: undefined reference to 'XftColorFree'
/home/vanessa/.cabal/store/ghc-8.6.3/xmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3/lib/libHSxmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3.a(MinXft.o):r30wK_info: error: undefined reference to 'XftFontClose'
/home/vanessa/.cabal/store/ghc-8.6.3/xmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3/lib/libHSxmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3.a(MinXft.o):xmobarzm0zi29zi4zm9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3_XmobarziX11ziMinXft_zdwwithAXftDraw_info: error: undefined reference to 'XftDrawCreate'
/home/vanessa/.cabal/store/ghc-8.6.3/xmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3/lib/libHSxmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3.a(MinXft.o):xmobarzm0zi29zi4zm9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3_XmobarziX11ziMinXft_zdwwithAXftDraw_info: error: undefined reference to 'XftDrawDestroy'
/home/vanessa/.cabal/store/ghc-8.6.3/xmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3/lib/libHSxmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3.a(MinXft.o):s30yi_info: error: undefined reference to 'XftColorAllocName'
/home/vanessa/.cabal/store/ghc-8.6.3/xmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3/lib/libHSxmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3.a(MinXft.o):s30Ae_info: error: undefined reference to 'XftDrawStringUtf8'
/home/vanessa/.cabal/store/ghc-8.6.3/xmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3/lib/libHSxmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3.a(MinXft.o):s30AU_info: error: undefined reference to 'XftDrawStringUtf8'
/home/vanessa/.cabal/store/ghc-8.6.3/xmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3/lib/libHSxmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3.a(MinXft.o):xmobarzm0zi29zi4zm9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3_XmobarziX11ziMinXft_drawXftRect1_info: error: undefined reference to 'XftDrawRect'
/home/vanessa/.cabal/store/ghc-8.6.3/xmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3/lib/libHSxmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3.a(MinXft.o):s30GW_info: error: undefined reference to 'XftFontOpenName'
/home/vanessa/.cabal/store/ghc-8.6.3/xmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3/lib/libHSxmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3.a(MinXft.o):s30IZ_info: error: undefined reference to 'XftTextExtentsUtf8'
/home/vanessa/.cabal/store/ghc-8.6.3/xmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3/lib/libHSxmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3.a(MinXft.o):s30KG_info: error: undefined reference to 'XftCharExists'
/home/vanessa/.cabal/store/ghc-8.6.3/xmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3/lib/libHSxmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3.a(MinXft.o):xmobarzm0zi29zi4zm9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3_XmobarziX11ziMinXft_zdwdrawXftStringzq_info: error: undefined reference to 'XftDrawDisplay'
/home/vanessa/.cabal/store/ghc-8.6.3/xmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3/lib/libHSxmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3.a(EventLoop.o):xmobarzm0zi29zi4zm9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3_XmobarziAppziEventLoop_zdwstartLoop_info: error: undefined reference to 'XftInitFtLibrary'
/home/vanessa/.cabal/store/ghc-8.6.3/xmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3/lib/libHSxmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3.a(ColorCache.o):xmobarzm0zi29zi4zm9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3_XmobarziX11ziColorCache_zdwwithDrawingColors_info: error: undefined reference to 'XftDrawCreate'
/home/vanessa/.cabal/store/ghc-8.6.3/xmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3/lib/libHSxmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3.a(ColorCache.o):xmobarzm0zi29zi4zm9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3_XmobarziX11ziColorCache_zdwwithDrawingColors_info: error: undefined reference to 'XftDrawDestroy'
/home/vanessa/.cabal/store/ghc-8.6.3/xmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3/lib/libHSxmobar-0.29.4-9ca55ed043d8ae4bcd864a821339381124cf5027ce5b58f18f1f925350ec86a3.a(Draw.o):s3nB7_info: error: undefined reference to 'XftDrawRect'
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
```
In order to fix this, I have to run

```
PKG_CONFIG_PATH=/home/vanessa/.cpkg/libXft-2.3.2-469cf1f92ca0db34/lib/pkgconfig cabal new-build --extra-lib-dirs=/home/vanessa/.cpkg/libXft-2.3.2-469cf1f92ca0db34/lib
```

The thing is, passing `--extra-lib-dirs` like this is a bit silly - that information is already provided by the `.pc` file, viz.

```
PKG_CONFIG_PATH=/home/vanessa/.cpkg/libXft-2.3.2-469cf1f92ca0db34/lib/pkgconfig pkg-config --libs-only-L xft
```

yields

```
-L/home/vanessa/.cpkg/libXft-2.3.2-469cf1f92ca0db34/lib
```

...which is nearly what we had to pass to `--extra-lib-dirs`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.