do I have to specify the path to the header
This depends if the header (#include
) file of library A contains an #include
line which includes the header file of library B.
Most developers of libraries try to avoid this so you can even use library A if you do not have the header files of library B!
(Which of course means that you do not have to specify the path to the header files.)
and the library file of library B to a compiler such as gcc?
If library A is a static library (.a
) you definitely have to specify library B:
It does not matter if library B is static (.a
) or shared (.so
). However if library B is static (.a
) and uses a library C you also have to specify library C. And if library C uses a library D...
If library A is a shared library (.so
) it depends on the operating system used:
Using very, very old Linux variants (late 1990s) you had to specify library B (and library C ...).
Maybe there are still operating systems which have this behaviour.
Under recent Linux variants you don't have to specify library B if library A is a shared library. The same is true for (all versions of?) Windows.