Do I need to link statically linked libraries with their dependencies?
You may need to link to both libraries depending on how A. was built.
If A contains a linker comment entry indicating that the linker also looks in library B for symbols (usually included in one of the object files contained in A), then you do not need to include B when linking. If A does not contain this comment entry, you must enable it yourself.
source to share
If both A and B are static, then you must concatenate both, in order A, then B ( -la -lb
). See this answer for an explanation of the order.
A statically linked program includes the libraries linked to it inside the executable.
Imagine that your program calls foo()
inside A, and somewhere inside A is bar()
called. So if A becomes part of your program, you then call undefined in bar()
in your program, so you also need to set a reference to B.
The exception is that a custom Visual Studio pragma ( #pragma comment(lib, libname)
) is used as @ 1201ProgramAlarm pointed out.
source to share