GP2X Need Help Setting Up Gp2x Cross Compiling With Sdl Under Ubuntu


Status
Not open for further replies.

CCmachined

Member
Joined
Nov 3, 2007
Messages
347
hi, i just installed the open2x toolchain for Linux (open2x-libpack-20071903-gcc-4.1.1-glibc-2.3.6.tar.bz2 and arm-open2x-linux-apps-gcc-4.1.1-glibc-2.3.6_i686_linux.tar.bz2) by extracting them into /opt. i'm not doing this as root; i gave myelf permissions to /opt/.

i'm compiling the SDL Hello World in the gp2x wiki, but with the header changed from "SDL.h" to "SDL/SDL.h" as it is inside the libs pack.

here's the output:
QUOTE

ccmachine@andrewiv-portable:/opt/open2x/gcc-4.1.1-glibc-2.3.6$ ./bin/arm-open2x-linux-g++ ~/gp2x/sdl_hello_world.cpp -lSDL -o ~/gp2x/sdl_hello_world2x.out
/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/../lib/gcc/arm-open2x-linux/4.1.1/../../../../arm-open2x-linux/bin/ld: cannot find -lSDL
collect2: ld returned 1 exit status
ccmachine@andrewiv-portable:/opt/open2x/gcc-4.1.1-glibc-2.3.6$



i've tried "-lSDL/SDL" and "-lSDLmain" as used by mingw32, but they all cannot be found. i tried adding "/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin" to my path by running "PATH=$PATH:/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin" but then, it fails to find the header file "SDL/SDL.h". Help!
 
wow thanks! is there any way i can automate that, by putting it in my path or so?

can this be added to the wiki? i'm sure this confuses many trying to set up a dev environment...
 
Nope, you always have to tell it where the libraries are stored when cross compiling (unless you are using autotools, and that will set it up for you but it can get quite complex). A bit of a pain, but what can you do?
 
k, thanks.

Argh... i just noticed that if i use -lSDL_image, the compiler spits out a load of "undefined reference" errors, most likely caused by this:

ccmachine@andrewiv-portable:/media/sda7/ccmachine/c++/sdl/lesson02_gp2x$ sh cross-gp2x-compile.sh
/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/../lib/gcc/arm-open2x-linux/4.1.1/../../../../arm-open2x-linux/bin/ld: warning: libjpeg.so.62, needed by /opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL_image.so, not found (try using -rpath or -rpath-link)
/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/../lib/gcc/arm-open2x-linux/4.1.1/../../../../arm-open2x-linux/bin/ld: warning: libpng12.so.0, needed by /opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL_image.so, not found (try using -rpath or -rpath-link)
/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/../lib/gcc/arm-open2x-linux/4.1.1/../../../../arm-open2x-linux/bin/ld: warning: libz.so.1, needed by /opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL_image.so, not found (try using -rpath or -rpath-link)
/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/../lib/gcc/arm-open2x-linux/4.1.1/../../../../arm-open2x-linux/bin/ld: warning: libfreetype.so.6, needed by /opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL_ttf.so, not found (try using -rpath or -rpath-link)
/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/../lib/gcc/arm-open2x-linux/4.1.1/../../../../arm-open2x-linux/bin/ld: warning: libsmpeg-0.4.so.0, needed by /opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL_mixer.so, not found (try using -rpath or -rpath-link)

am I missing some files? the file compiles just fine without -lSDL_image, so it's definitely something to do with my setup.
 
Instead of typing it everytime on the command line, you can put all your options inside a makefile, then you'll just type 'make' and it'll do everything for you :)

As for stuff like 'libjpeg.so.62' missing, are you sure you have libjpeg v6? if so, just create a simlink to it.
 
Squidge said:
Instead of typing it everytime on the command line, you can put all your options inside a makefile, then you'll just type 'make' and it'll do everything for you :)

As for stuff like 'libjpeg.so.62' missing, are you sure you have libjpeg v6? if so, just create a simlink to it.
a quick search shows "libjpeg.so.62" and the other libs it complains about are in /opt/open2x/gcc-4.1.1-glibc-2.3.6/lib... hm, "libjpeg.so.62" is a link, it points to libjpeg.so.62.0.0 in the same directory. ?

sorry but i'm a newbie to all this... im used to a simple "apt-get install libsdl-image" :D
 
Last edited by a moderator:
Or you can make a quick shell script to place in $HOME/bin, like this:

CODE
arm-open2x-linux-g++ -L/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib -I/usr/include $*


Or something of the sort.
In doing so, you can also make the command-line shorter: gp2x-g++ as opposed to arm-open2x-linux-g++ , I do this, simply because
I'm lazy. ;)
 
Last edited by a moderator:
Thanks for your suggestion, but please read the rules of the board before posting next time, as posting in threads over three months old is considered bad forum etiquette.
 
Status
Not open for further replies.
Back
Top