Menu

#201 pkg-config static libraries don't work

4.9
closed
nobody
None
4
2012-10-09
2009-04-11
Peter Wang
No

$(pkg-config --libs --static allegro-4.9) doesn't actually work. The
problem is that pkg-config will spit out -lallegro-4.9 when our static
library is called liballegro-static-4.9.a. But also pkg-config isn't
smart enough to write the full path to the .a file, so if you have
liballegro-static-4.9.so installed as well that will be used instead.

Discussion

  • Elias Pschernig

    Elias Pschernig - 2009-05-06

    I think pkg-config is too dumb to do this right - the only way is to have separate packages for static and dynamic versions so I changed it to do that. Now you can do:

    "pkg-config --libs --static allegro-static-4.9" and it should work as intended.

     
  • Thomas Fjellstrom

    I think it expects that libs have the same name (and probably should on linux, I don't see a need for them to have different base names imo).

    Whats the reason for them having different names again? libfoo.so is the shared lib and libfoo.a is the static lib in most cases.

     
  • Elias Pschernig

    Elias Pschernig - 2009-05-06

    Even with the same name it would pick the wrong one (libfoo.so instead of libfoo.a). pkg-config basically is not very well designed from the beginning (or at least with no thought about static linking) - but it still is really useful for the bit it does right.

    Do you know of any project which uses pkg-config to enable static linking, without using separate .pc files? If so, we can look how they do it of course. But I don't see any solution.

     
  • Peter Wang

    Peter Wang - 2009-07-07

    Reopening as it's still not quite right. e.g. in the following a5_iio-static-profile pulls in the shared version of liballegro-profile, not the static library.

    % pkg-config --libs a5_iio-static-profile-4.9
    -L/usr/local/stow/allegro-4.9.12/lib -la5_iio-profile-static-4.9.12 -lallegro-profile-4.9.12

     
  • Peter Wang

    Peter Wang - 2009-07-17

    Works now except kcm_audio doesn't pull in ALSA, etc.

     

Log in to post a comment.