I am currently working on a bigger project with a lot of libraries included and I have some questions about why gcc under linux behaves the way it does.
First, as I think you might be aware, you can use the "-lxyz" linker flag to gcc/g++ to search for libxyz.so in some system paths and link to it. However, this does not work in the case of static libraries, i.e. if I want to link against libxyz.a I have to add /usr/lib/libxyz.a as an object file explicitely.
My problem is the following: If I want to include a pkg-config style .pc file in my project, what should I put in it if the user chooses to build a static library?
Also, I found it rather annoying that gcc/g++ does not handle library dependencies the way I would expect:
If I link my program against a libabc.so and if ldd tells me that libabc.so depends on libxyz.so then I think that gcc/g++ should be smart enough to also link against libxyz.so. Sadly, this seems not to be the case. Is there any good reason why this does not work or is there a possibility to force gcc/g++ to consider these dependencies?
gcc -vinstead of justgccand that would show you what is happening.