How to use pkg-config to link a library statically

前端 未结 4 806
心在旅途
心在旅途 2021-01-05 12:08

I\'d like to link libpng found by pkg-config statically.

pkg-config --libs --static libpng

outputs

-L/usr/local/Cell

4条回答
  •  一生所求
    2021-01-05 12:59

    The pkg-config --static option relies on proper tagging in the .pc files. If providing the --static option does not return correct information necessary to link against the libpng archive, then you cannot use pkg-config for that purpose.

    I suspect libpng (along with a majority of other packages) dropped support for static linking some time after libpng 1.2. They may still provide a library archive, but the libpng pkg-config file is no longer properly tagged to support a static link. You will have to manually tell ld to use the static lib.

提交回复
热议问题