Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error linking with sdl while crosscompiling application for ARM

I'm trying to crosscompile simple SDL application for ARM processor.

I'm using Motorola A1200 with Intel Xscale PX27x rev 7 (with iwmmxt extension) processor And modified crosscompiling toolchain with for example, gcc:

arm-linux-gnu-g++ --version
arm-linux-gnu-g++ (GCC) 3.3.6
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ arm-linux-gnu-g++ -v
Reading specs from /opt/crosstool/bin/../lib/gcc-lib/arm-linux-gnu/3.3.6/specs
Configured with: /home/nuso2f/mkezx-0.9.20/build/host/crosstool-ezx/configure --host=i486-host_linux-gnu --target=arm-linux-gnu --prefix=/home/nuso2f/mkezx-0.9.20/build/host/crosstool-ezx.fake_root --with-cpu=iwmmxt --enable-cxx-flags=-mcpu=iwmmxt --with-float=soft --with-headers=/home/nuso2f/mkezx-0.9.20/build/host/crosstool-ezx.fake_root/arm-linux-gnu/include --with-local-prefix=/home/nuso2f/mkezx-0.9.20/build/host/crosstool-ezx.fake_root/arm-linux-gnu --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++,f77 --enable-shared --enable-c99 --enable-long-long
Thread model: posix
gcc version 3.3.6

To be honest, this compiler was compiled not by me, so paths stated above are not valid.

And some directory with libraries like libSDL libSDL_mixer and so on I've checked all this libraries if they are for ARM.

$ file *.so*
ELF 32-biarm-linux-gnu-g++ ttt.cpp -o ttt.arm -I/usr/include -L`pwd`

So they are.

Then I have copied libSDL-1.2.so to the project directory. Checked symbols from that library

readelf --syms libSDL-1.2.so

All fine.

And then tried to compile: (Note that arm-linux-gnu-g++ ($CXX) and other corresponding environmental variables, such as $LD, $AR and other are set corresponding to crosscompile toolchain location)

$ arm-linux-gnu-g++ ttt.cpp -o ttt.arm -I/usr/include -L`pwd`
/tmp/ccXpDX0V.o(.text+0xb0): In function `main':
: undefined reference to `SDL_Init'
/tmp/ccXpDX0V.o(.text+0xd8): In function `main':
: undefined reference to `SDL_SetVideoMode'
/tmp/ccXpDX0V.o(.text+0x170): In function `main':
: undefined reference to `SDL_UpperBlit'
/tmp/ccXpDX0V.o(.text+0x17c): In function `main':
: undefined reference to `SDL_Flip'
/tmp/ccXpDX0V.o(.text+0x1c8): In function `main':
: undefined reference to `SDL_PollEvent'
/tmp/ccXpDX0V.o(.text+0x2d8): In function `$a':
: undefined reference to `SDL_FillRect'
/tmp/ccXpDX0V.o(.text+0x334): In function `myabort(char const*)':
: undefined reference to `SDL_GetError'
/tmp/ccXpDX0V.o(.text+0x380): In function `my_img_load(char*)':
: undefined reference to `SDL_RWFromFile'
/tmp/ccXpDX0V.o(.text+0x390): In function `my_img_load(char*)':
: undefined reference to `SDL_LoadBMP_RW'
/tmp/ccXpDX0V.o(.text+0x3b8): In function `my_img_load(char*)':
: undefined reference to `SDL_DisplayFormatAlpha'
/tmp/ccXpDX0V.o(.text+0x3c8): In function `my_img_load(char*)':
: undefined reference to `SDL_FreeSurface'
collect2: ld returned 1 exit statust LSB shared object, ARM, version 1, dynamically linked, stripped

Though when I'm trying to compile like this

arm-linux-gnu-g++ ttt.cpp -o ttt.arm -I/usr/include ./libSDL-1.2.so

It does compile and link (I hope) against SDL, but there are another link errors but with symbols from qt library (with which SDL is linked, I think), so it is NOT solution, because I don't know to which libraries those symbols belong.

So the questions are:

Am I doing something fundamentally wrong with dynamic linking?

Why -L option doesn't help gcc link with libraries in that dir?

Can I force compiling my program without this libraries at all (well, I need them to run program on device anyway) and load it at runtime?

like image 414
3demax Avatar asked Apr 22 '26 23:04

3demax


1 Answers

-L just adds a library search directory. Try also specifying -lSDL-1.2 or -lSDL to actually link against a library.

like image 165
genpfault Avatar answered Apr 25 '26 12:04

genpfault