C++ linked statically?

Piotr Borys piotr.borys@gmail.com
Wed May 27 22:59:00 GMT 2009

2009/5/26 Piotr Borys <piotr.borys@gmail.com>:
> 2009/5/26 Dimitry Andric <dimitry@andric.com>:
>> This is because you are using g++, which automagically adds the
>> -lstdc++.  So please try using 'gcc' instead of 'g++'.
> ok, it built it this time, using gcc. But... the problem returned:
> $ ./parking
> Illegal instruction
> :(((

OK, I've managed to make it :))

First, I've made a symlink to static version of libstdc++ in my sources dir:

ln -s `arm-unknown-linux-uclibcgnueabi-g++ -print-file-name=libstdc++.a`

and then, in Makefile:

CC = $(CROSS)g++
LDFLAGS = -v -static-libgcc -L.

Notice it *has* to be g++, as gcc produces illegal code. After forcing
it to link libgcc statically and moving it to our isolated directory,
it linked libstdc++ statically - and the final code works properly on
a target machine! :D

Piotr "utak3r" Borys

For unsubscribe information see http://sourceware.org/lists.html#faq

More information about the crossgcc mailing list