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-
ARCH=arm
CC = $(CROSS)g++

CFLAGS = -Wall -march=armv4t
#LDFLAGS = -Wl,-rpath -Wl,/usr/lib -Wl,-rpath-link
-Wl,$(STAGING_DIR)/arm-unknown-linux-uclibcgnueabi/lib
-L$(STAGING_DIR)/arm-unknown-linux-uclibcgnueabi/lib
#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
-L$(STAGING_DIR)/arm-unknown-linux-uclibcgnueabi/sys-root/usr/lib
#LDFLAGS =
LDFLAGS = -L$(STAGING_DIR)/arm-unknown-linux-uclibcgnueabi/lib
--static -lstdc++ -lc

SRC := main.cpp \
        serial.cpp

OBJ := main.o \
        serial.o

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

all: $(APP)

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

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


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


cheers
-- 
Piotr "utak3r" Borys
http://utak3r.pl

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



More information about the crossgcc mailing list