This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Static Linking stdc++
- From: bjorn rohde jensen <bjensen at fastmail dot fm>
- To: DrEvil <drevil at warpcore dot org>
- Cc: GCC Help <gcc-help at gcc dot gnu dot org>
- Date: Wed, 13 Nov 2002 10:41:49 +0100
- Subject: Re: Static Linking stdc++
- References: <1037050891.12090.15.camel@virtucon.warpcore.org>
- Reply-to: bjensen at fastmail dot fm
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