g++ linking order dependency when linking c code to c++ code

The order you specify object files and libraries is VERY important in GCC – if you haven’t been bitten by this before you have lead a charmed life. The linker searches symbols in the order that they appear, so if you have a source file that contains a call to a library function, you need to put it before the library, or the linker won’t know that it has to resolve it. Complex use of libraries can mean that you have to specify the library more than once, which is a royal pain to get right.

Leave a Comment