Ld: Could Not Read Symbols: File In Wrong Format


u9i

Call me Uni
Joined
Jun 27, 2008
Messages
761
Age
48
Location
Faroe Islands
Website
riotdigital.com
Hi everyone

Could someone help me out please. I have followed torpor's guide ( http://www.gp32x.de/board/index.php?/topic/48635-a-slightly-more-complete-toolchain-libs-for-linux-devs/ ) to getting a build environment up and running on my computer and i have been able to compile a simple SDL (hello pixel) program. But when i take a bigger project it seems the linker is trying to link with the x86 libraries instead of the arm ones (my guess).

Here is my makefile:

Code:
OPEN2X = /opt/openwiz/toolchain

CC = $(OPEN2X)/bin/arm-openwiz-linux-gnu-gcc
LD = $(CC)
STRIP = $(OPEN2X)/bin/arm-openwiz-linux-gnu-strip

NAME=crazy
TARGET= $(NAME).gpe

DEFS = -DGP2X -DIS_LITTLE_ENDIAN -D_REENTRANT -DGP2X_ASM

INCS =  -I. -I$(OPEN2X)/include -I$(OPEN2X)/include/SDL

LDFLAGS=$(CFLAGS) -L$(OPEN2X)/lib
LIBS = -Wl,-rpath,$(OPEN2X)/lib -lSDLmain -lSDL -lSDL_image -lSDLgfx -lSDL_mixer -lSDL_ttf -lpng -lm -lz -lpthread

OBJS = customer.o floattext.o gamescene.o hud.o ingredient.o introscene.o leveldata.o machineinstant.o machinetimebased.o main.o player.o popup.o product.o progressbar.o score.o selector.o soundplayer.o sprite.o textsprite.o trashcan.o utils.o

MYCC = $(CC) $(CFLAGS) $(INCS) $(DEFS)

########################################################################

sdl: $(TARGET)

$(TARGET): $(OBJS)
	$(LD) $(LDFLAGS) $(OBJS) -o $@ $(LIBS)
	$(STRIP) $@

.c.o:
	$(MYCC) -c $< -o $@

clean:
	rm -f *.o *.gpe

And the output from make is:

Code:
u9@vital104:~/Documents/development/crazy_sundaes/src$ make
g++    -c -o customer.o customer.cpp
g++    -c -o floattext.o floattext.cpp
g++    -c -o gamescene.o gamescene.cpp
g++    -c -o hud.o hud.cpp
g++    -c -o ingredient.o ingredient.cpp
g++    -c -o introscene.o introscene.cpp
g++    -c -o leveldata.o leveldata.cpp
g++    -c -o machineinstant.o machineinstant.cpp
g++    -c -o machinetimebased.o machinetimebased.cpp
g++    -c -o main.o main.cpp
g++    -c -o player.o player.cpp
g++    -c -o popup.o popup.cpp
g++    -c -o product.o product.cpp
g++    -c -o progressbar.o progressbar.cpp
g++    -c -o score.o score.cpp
g++    -c -o selector.o selector.cpp
g++    -c -o soundplayer.o soundplayer.cpp
g++    -c -o sprite.o sprite.cpp
g++    -c -o textsprite.o textsprite.cpp
g++    -c -o trashcan.o trashcan.cpp
g++    -c -o utils.o utils.cpp
/opt/openwiz/toolchain/bin/arm-openwiz-linux-gnu-gcc  -L/opt/openwiz/toolchain/lib customer.o floattext.o gamescene.o hud.o ingredient.o introscene.o leveldata.o machineinstant.o machinetimebased.o main.o player.o popup.o product.o progressbar.o score.o selector.o soundplayer.o sprite.o textsprite.o trashcan.o utils.o -o crazy.gpe -Wl,-rpath,/opt/openwiz/toolchain/lib -lSDLmain -lSDL -lSDL_image -lSDLgfx -lSDL_mixer -lSDL_ttf -lpng -lm -lz -lpthread
/toolchain/bin/../lib/gcc/arm-openwiz-linux-gnu/4.2.4/../../../../arm-openwiz-linux-gnu/bin/ld: customer.o: Relocations in generic ELF (EM: 3)
/toolchain/bin/../lib/gcc/arm-openwiz-linux-gnu/4.2.4/../../../../arm-openwiz-linux-gnu/bin/ld: customer.o: Relocations in generic ELF (EM: 3)
/toolchain/bin/../lib/gcc/arm-openwiz-linux-gnu/4.2.4/../../../../arm-openwiz-linux-gnu/bin/ld: customer.o: Relocations in generic ELF (EM: 3)
/toolchain/bin/../lib/gcc/arm-openwiz-linux-gnu/4.2.4/../../../../arm-openwiz-linux-gnu/bin/ld: customer.o: Relocations in generic ELF (EM: 3)
/toolchain/bin/../lib/gcc/arm-openwiz-linux-gnu/4.2.4/../../../../arm-openwiz-linux-gnu/bin/ld: customer.o: Relocations in generic ELF (EM: 3)
/toolchain/bin/../lib/gcc/arm-openwiz-linux-gnu/4.2.4/../../../../arm-openwiz-linux-gnu/bin/ld: customer.o: Relocations in generic ELF (EM: 3)
/toolchain/bin/../lib/gcc/arm-openwiz-linux-gnu/4.2.4/../../../../arm-openwiz-linux-gnu/bin/ld: customer.o: Relocations in generic ELF (EM: 3)
/toolchain/bin/../lib/gcc/arm-openwiz-linux-gnu/4.2.4/../../../../arm-openwiz-linux-gnu/bin/ld: customer.o: Relocations in generic ELF (EM: 3)
/toolchain/bin/../lib/gcc/arm-openwiz-linux-gnu/4.2.4/../../../../arm-openwiz-linux-gnu/bin/ld: customer.o: Relocations in generic ELF (EM: 3)
customer.o: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make: *** [crazy.gpe] Error 1

I am thinking maybe it should be calling /toolchain/arm-openwiz-linux-gnu-ld instead of /toolchain/arm-openwiz-linux-gnu/bin/ld, but what do i know. I think at least it is using the wrong c++ libraries.

Does anyone have any ideas how to solve this problem?

Thanks
Uni
 
Last edited by a moderator:
I think your problem is that your Makefile doesn't define the variable for C++ compiler just the C compiler. At the end, Make uses the default one (ie, for PC, not Wiz).
Try to add this line near for CC = ...

Code:
CXX = $(OPEN2X)/bin/arm-openwiz-linux-gnu-g++
 
Thanks Rodolfo

That could be the fix. I added the line, but now my compiler cannot find the SDL includes.. As you have probably figured out, i know nothing about makefiles.

Is there some setting i need to add more for the C++ compiler to find the include directories?

My makefile is copied from the guide, so i am wondering, is this line used, and if so, should i change it to use CXX:

Code:
MYCC = $(CC) $(CFLAGS) $(INCS) $(DEFS)
 
Thanks notaz. That got me closer to compiling. I just needed to change the LD variable, and it works. I'm not gonna compile any C anyways, so i'm happy for now :)

Here is my current makefile if it can help anyone. Just don't use it for C ;)

Code:
OPEN2X = /opt/openwiz/toolchain

CC = $(OPEN2X)/bin/arm-openwiz-linux-gnu-gcc
CXX = $(OPEN2X)/bin/arm-openwiz-linux-gnu-g++
LD = $(CXX)
STRIP = $(OPEN2X)/bin/arm-openwiz-linux-gnu-strip

NAME=test
TARGET= $(NAME).gpe

DEFS = -DGP2X -DIS_LITTLE_ENDIAN -D_REENTRANT -DGP2X_ASM

INCS =  -I. -I$(OPEN2X)/include -I$(OPEN2X)/include/SDL

LDFLAGS=$(CFLAGS) -L$(OPEN2X)/lib
LIBS = -Wl,-rpath,$(OPEN2X)/lib -lSDL -lpng -lm -lz -lpthread

OBJS = main.o

MYCC = $(CC) $(CFLAGS) $(INCS) $(DEFS)
MYCXX = $(CXX) $(CFLAGS) $(INCS) $(DEFS)

########################################################################

sdl: $(TARGET)

$(TARGET): $(OBJS)
	$(LD) $(LDFLAGS) $(OBJS) -o $@ $(LIBS)
	$(STRIP) $@

.c.o:
	$(MYCC) -c $< -o $@

.cpp.o:
	$(MYCXX) -c $< -o $@

clean:
	rm -f *.o *.gpe
 
Ah, you're thinking because of my object list?

OBJS = customer.o floattext.o gamescene.o hud.o ingredient.o introscene.o leveldata.o machineinstant.o machinetimebased.o main.o player.o popup.o product.o progressbar.o score.o selector.o soundplayer.o sprite.o textsprite.o trashcan.o utils.o

Well, to be honest my gf is making a game for the GP2x, which i am trying to compile for the Wiz. I hope she will be allowed to release it, since it is pretty good. But there is a corporate entity involved, and they are never very happy with giving stuff away.

The objects list does give some hints though: ingredient, machineinstant, machinetimebased, customer, trashcan :) I'll leave it up to your imagination until it is finished.

Thanks torpor for putting the libs with the toolchain though. And thanks to Orkie as well. And Pickle. You guys have saved me many many headache-filled hours (days/weeks even, in my case). I haven't tried, but i am pretty sure i can figure out how to add libraries now, and who knows, I might even be able to compile/port my own.

/Uni
 
Back
Top