This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Static Linking stdc++


On Wed, 2002-11-13 at 03:41, bjorn rohde jensen wrote:
> 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.

I see, thanks for the information. This is exactly what I needed to
know. However it greatly disappoints me that it's this complicated. It
seems as though this is an oversight on the part of the gcc 3 people. It
was much easier to static link stdc++ with the 2.x series.

Thanks.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]