C++ linked statically?

Piotr Borys piotr.borys@gmail.com
Tue May 26 17:06:00 GMT 2009

Hello all,

I've built arm-linux-uclibcgnueabi toolchain with the help of this
fantastic tool :)
Now I have a problem - building C apps is ok, all is working as
expected, but I can't get a working C++ app.
As I'm really short of space on my target device, I can't afford
copying whole shared libraries, so I'm trying to link them statically.
I've tried several ways, starting from adding -static to my CFLAGS,
but everytime it ends up with a binary, which after executing on a
target machine gives me "Illegal instruction" and crashes :/

my last attempt for a Makefile is as follows (you can notice my
various tries at LDFLAGS here)

APP = parking

STAGING_DIR = /home/utak3r/crosstool/arm-unknown-linux-uclibcgnueabi
CROSS = $(STAGING_DIR)/bin/arm-unknown-linux-uclibcgnueabi-
CC = $(CROSS)g++

CFLAGS = -Wall -march=armv4t
#LDFLAGS = -Wl,-rpath -Wl,/usr/lib -Wl,-rpath-link
#CFLAGS = -Wall -O2 -g -pthread -DLINUX -D_GNU_SOURCE
#LDFLAGS =  -lpthread -s -Wl,-warn-common -lc
#LDFLAGS = -s -Wl,-warn-common --static -lstdc++
#LDFLAGS = -L$(STAGING_DIR)/arm-unknown-linux-uclibcgnueabi/sys-root/lib
LDFLAGS = -L$(STAGING_DIR)/arm-unknown-linux-uclibcgnueabi/lib
--static -lstdc++ -lc

SRC := main.cpp \

OBJ := main.o \

        $(CC) $(CFLAGS) -I. -c -o $@ $<

all: $(APP)

$(APP): $(OBJ)
        $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
        $(CROSS)strip $@
        $(CROSS)size $@
        @echo Zrobione.

        rm -f *.o *.gdb $(APP)

        @echo Kopiuje program na serwer FTP...
        @/bin/bash ./install.sh

Piotr "utak3r" Borys

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

More information about the crossgcc mailing list