Static Linking stdc++

bjorn rohde jensen bjensen@fastmail.fm
Wed Nov 13 01:41:00 GMT 2002


Hi there,

  You should not use gcc to link a c++ program,
it is a much better idea to use g++ and tell
it not to link in the standard files and such.

On my system i made this work using:

LD = /usr/local/gcc3.2/bin/g++
LDFLAGS = -O3 -nostdlib
LDPATH =
LDLIBS = /usr/lib/crt1.o /usr/lib/crti.o 
/usr/local/gcc3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/crtbegin.o 
-L/usr/local/gcc3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2 
-L/usr/local/gcc3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../.. 
-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc 
/usr/local/gcc3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/crtend.o /usr/lib/crtn.o

As you can see, g++ arranges for the linking with quite a
few supporting libraries:) I found the proper ones by telling
g++ to be verbose (-v) during linking.

Yours sincerely,

Bjorn



More information about the Gcc-help mailing list