I have the following problem which does not seem to have a good solution.
For example, I have a CLI utility that uses libtiff and libX11. I want to create two versions of this utility: dynamically linked and statically linked (with the maximum possible number of compiled dependencies).
For dynamic linking, everything works like a charm: you need to specify -ltiff -lX11, and the linker will create a good executable libtiff.soand libX11.so.
The situation is getting worse for static binding. When I use the following command:
g++ -static-libgcc -Wl,-static -o my.out *.o -lc -ltiff -lX11
it ends with missing characters in libtiff.a and libX11.a. Well, I can put all the libraries on which they depend on a line:
g++ -static-libgcc -Wl,-static -o my.out *.o -lc -ltiff -ljpeg -lz -lX11 -lXau -lxcb -lXdmcp
but is there any tool that makes this discovery for me? Can libtool help here (I see /usr/lib/libtiff.la, but not /usr/lib/libX11.la)? Can someone provide a basic example for libtool, please? The situation is crucial if on some platform it libtiffprovides narrower functionality and is not tied to libjpeg, which will not be available on this platform at all, therefore the above linking command will fail due to an unsatisfied library dependency.
The second problem is related to this warning (I believe):
/usr/lib/libX11.a(xim_trans.o): In function `_XimXTransSocketUNIXConnect':
(.text+0xcda): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
The utility is not statically linked to libc, which is still displayed in the output ldd. How to link statically with libX11and libcin this case?
, , .a .