This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: about order of the libraries at link time
"Lijuan Hai" <hailijuan@gmail.com> writes:
> g++ always add "-lstdc++ -lm" before any other libraries at link
> time. I want to link the libraries after libc.so. but I haven't found
> where to change the order in gcc sources. so could you provide any
> helpful hints on it? thanks in advance.
gcc/cp/g++spec.c.
To be precise g++ adds "-lstdc++ -lm" after almost all libraries but
before "-lc". This is normally correct as -lstdc++ depends on -lc,
therefore -lc must follow -lstdc++. If you want to have -lstdc++
after -lc, you will need to use a --start-group (assuming you are
using the GNU linker). Admittedly g++ is probably going to mess up a
--start-group which involves -lc, although I haven't tried it.
Ian