I have a situation where I need to compile C code and C++ code aswell as linking to a C++ static libary.
This works by using the following command:
gcc file.cpp file.c -xc++ -pthread -std=c++11 -lstdc++ -shared-libgcc -L/path -l:liba.a -lm -o program
However, if I change the order of link commands (switching -lm
and -l:libary.a
) as follows:
gcc file.cpp file.c -xc++ -pthread -std=c++11 -lstdc++ -shared-libgcc -lm -L/path -l:liba.a -o program
This does not work as the compiler complains:
liba.o: undefined reference to symbol 'log@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
Why this happens?