Why does the order in which libraries are linked sometimes cause errors in GCC?


Basically this kind of errors are originated from the linker in the compilation phase. The default behavior of a linker is to take the code from archive libraries when the current program needs it.

To work properly the libraries must be present in order. We can say that it must be there in the form “caller before callees”. This problem can be solved by choosing non-default behavior using flags, but in this process the linking may take larger time. Otherwise it can be solved by ordering the libraries correctly. Loaders and tsort these two can help to rearrange and correct the ordering.

Updated on: 30-Jul-2019

94 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements