I'm trying to build a project that depends on binary distributed static libraries.
The linker complains it cannot find ini_config
functions, among others:
config_params.c:(.text+0x16f): undefined reference to `ini_get_config_valueobj'
It finds the dynamic libraries, but not the static version:
attempt to open /usr/lib/gcc/x86_64-linux-gnu/7/libini_config.a failed
attempt to open /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libini_config.so succeeded
Those files are present on debian stretch. Is there a way to get them on ubuntu as well ?
All packages seem to install their static libraries. They can be found in
/usr/lib/x86_64-linux-gnu
.Apparently, the linker first picks the dynamic libraries when using
-lsomelib
. To override that, you can use the-l:libsomelib.a
, it will then only match the exact filenamesomelib.a
. Use-L/usr/lib/x86_64-linux-gnu
the same way as for "linking" dynamic libraries.To debug the library searching phase, you can add
-Wl
,--verbose
to yourLDFLAGS
.gcc
will then display every path it tries for your-lXXX
options.Keep in mind that archives are checked only once, as stated in this answer, if some symbols are still not found, you maybe have to reorder the parameters.