Need Guidance


xyexz

Still Fresh
Joined
Dec 23, 2009
Messages
6
Hi all, just registered on these forums and have just received a Wiz from my wife as a present :D.
I'm not new to linux nor am I new to programming (.NET/PHP/SQL/AJAX etc), however I have been feverishly reading all over these forums, downloading everything I can find on these forums, openhandhelds.org and anything I can find on Google. I've follow countless tutorials on getting up a build environment in linux for compiling arm code for the Wiz and reached success on that front.
(takes a breath)...
What I haven't succeeded in yet is to get some sort of video output using SDL with the crosstool-ng build environment.
What I am really looking for is a simple tut that show a-z a simple program implementing SDL with a hello world graphic or something.
Is there anything like that for this?
I'll post again on here with the code i'm trying to compile that is using SDL lib and the errors i'm getting and what i've tried to do to get around them.

Thanks in advance to anyone who responds!
 
Ok here is my compile line:
$ arm-openwiz-linux-gnu-gcc -g -Wall `sdl-config --cflags` `sdl-config --static-libs` sdl_ex.c -o sdl_test.wiz.gpe

Here are the errors I receive:
/opt/arm-openwiz-linux-gnu/bin/../lib/gcc/arm-openwiz-linux-gnu/4.2.4/../../../../arm-openwiz-linux-gnu/bin/ld: warning: libts-0.0.so.0, needed by /usr/local/lib/libSDL.so, not found (try using -rpath or -rpath-link)
/opt/arm-openwiz-linux-gnu/bin/../lib/gcc/arm-openwiz-linux-gnu/4.2.4/../../../../arm-openwiz-linux-gnu/bin/ld: ERROR: /usr/local/lib/libSDL.so uses VFP instructions, whereas sdl_test.wiz.gpe does not
/opt/arm-openwiz-linux-gnu/bin/../lib/gcc/arm-openwiz-linux-gnu/4.2.4/../../../../arm-openwiz-linux-gnu/bin/ld: failed to merge target specific data of file /usr/local/lib/libSDL.so
... and the usual function calls missing errors because lib wasn't found

Here is my /usr/local/lib:
$ ls -l /usr/local/lib | grep libSDL
lrwxrwxrwx 1 root root 20 2009-12-23 14:47 libSDL-1.2.so.0 -> libSDL-1.2.so.0.11.3
-rwxr-xr-x 1 root root 983116 2009-12-22 15:38 libSDL-1.2.so.0.11.3
-rw-r--r-- 1 root root 284316 2009-12-23 14:39 libSDL-1.2.so.wiz.0
-rw-r--r-- 1 root root 1426116 2009-12-22 15:38 libSDL.a
-rwxr-xr-x 1 root root 946 2009-12-22 15:38 libSDL.la
-rw-r--r-- 1 root root 3318 2009-12-22 15:38 libSDLmain.a
lrwxrwxrwx 1 root root 19 2009-12-23 14:49 libSDL.so -> libSDL-1.2.so.wiz.0

I hard linked the libSDL-1.2.so.wiz.0 because I figure this was compiled with arm environment, mine was not.

$ ls -l /usr/local/lib | grep libts
lrwxrwxrwx 1 root root 23 2009-12-23 14:55 libts-0.0.so.0 -> /usr/lib/libts-0.0.so.0

I hard linked the libts-0.0.so.0 to try to fix the error and obviously it didn't work.

Also I read somewhere (can't remember now) that there is something I can turn off for the VPF error, (or a --flag?).

Anyways, suggestions would be great, I think it's all due to my libSDL, but how do I compile a version for arm, or am I way off base here?
 
Welcome!!

I think you are using the SDL libraries for PC (x86) from /usr/local/lib. You must use the SDL libraries in the toolchain (/opt/arm-openwiz-linux-gnu/bin/../lib) wich not have VFP and are compiled for ARM processor. You must to call the toolchain's 'sdl-config' command. Use an environment variable to hold then path and use `$(TOOLCHAIN)/bin/sdl-config --cflags` for example.

You can put this in your Makefile:

Code:
 TOOLCH = /opt/openwiz/toolchain/arm-openwiz-linux-gnu
  CC     = ${TOOLCH}/bin/arm-openwiz-linux-gnu-gcc
  CXX    = ${TOOLCH}/bin/arm-openwiz-linux-gnu-g++
  INCS   = -I${TOOLCH}/include -I${TOOLCH}/include/SDL
  LD     = ${TOOLCH}/bin/arm-openwiz-linux-gnu-g++
  LDFLAGS= -L${TOOLCH}/lib -lSDL -lm -ldl -lpthread -lz

Useful links:
SDL simplest example
Complete Wiz toolchain with SDL libraries
 
Last edited by a moderator:
Hardyx said:
Welcome!!

I think you are using the SDL libraries for PC (x86) from /usr/local/lib. You must use the SDL libraries in the toolchain (/opt/arm-openwiz-linux-gnu/bin/../lib) wich not have VFP and are compiled for ARM processor. You must to call the toolchain's 'sdl-config' command. Use an environment variable to hold then path and use `$(TOOLCHAIN)/bin/sdl-config --cflags` for example.

You can put this in your Makefile:

Code:
 TOOLCH = /opt/openwiz/toolchain/arm-openwiz-linux-gnu
  CC     = ${TOOLCH}/bin/arm-openwiz-linux-gnu-gcc
  CXX    = ${TOOLCH}/bin/arm-openwiz-linux-gnu-g++
  INCS   = -I${TOOLCH}/include -I${TOOLCH}/include/SDL
  LD     = ${TOOLCH}/bin/arm-openwiz-linux-gnu-g++
  LDFLAGS= -L${TOOLCH}/lib -lSDL -lm -ldl -lpthread -lz

Useful links:
SDL simplest example
Complete Wiz toolchain with SDL libraries

That is most likely what i'm doing for sure! Thanks a ton, i'll update when I get some time to check it out, holidays and all :D
 
Last edited by a moderator:
Ok so I was able to find some time to try it, I re-downloaded the lib and made sure I had all links and directories in the right order according to the link you pasted for the toolchain.
I then tried the command:
Code:
/opt/toolchain/bin/arm-openwiz-linux-gnu-gcc -g -Wall `${TOOLCHAIN}/bin/sdl-config --cflags` `${TOOLCHAIN}/bin/sdl-config --static-libs` sdl_ex.c -o sdl.wiz.gpe

Error:
/opt/toolchain/bin/../lib/gcc/arm-openwiz-linux-gnu/4.2.4/../../../../arm-openwiz-linux-gnu/bin/ld: cannot find -lSDL
collect2: ld returned 1 exit status

~/development/c++$ echo `${TOOLCHAIN}/bin/sdl-config --cflags`
-I/opt/openwiz/toolchain/arm-openwiz-linux-gnu/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT

~/development/c++$ echo `${TOOLCHAIN}/bin/sdl-config --static-libs`
-L/opt/openwiz/toolchain/arm-openwiz-linux-gnu/lib -Wl,-rpath,/opt/openwiz/toolchain/arm-openwiz-linux-gnu/lib -lSDL -lpthread

So then I tried a makefile:
Code:
TOOLCH = /opt/openwiz/toolchain/arm-openwiz-linux-gnu
  CC     = ${TOOLCH}/bin/arm-openwiz-linux-gnu-gcc
  CXX    = ${TOOLCH}/bin/arm-openwiz-linux-gnu-g++
  INCS   = -I${TOOLCH}/include -I${TOOLCH}/include/SDL
  LD     = ${TOOLCH}/bin/arm-openwiz-linux-gnu-g++
  LDFLAGS= -L${TOOLCH}/lib -lSDL -lm -ldl -lpthread -lz

sdl_ex: sdl_ex.o
        cc sdl_ex.o -o sdl_ex.gpe.wiz
sdl_ex.o: ${TOOLCHAIN}/include/SDL/SDL.h sdl_ex.c
        cc -c sdl_ex.c

Error:
$ make
cc sdl_ex.o -o sdl_ex.gpe.wiz
sdl_ex.o: In function `setpixel':
sdl_ex.c:(.text+0x3b): undefined reference to `SDL_MapRGB'
sdl_ex.o: In function `DrawScreen':
sdl_ex.c:(.text+0x91): undefined reference to `SDL_LockSurface'
sdl_ex.c:(.text+0x198): undefined reference to `SDL_UnlockSurface'
sdl_ex.c:(.text+0x1a3): undefined reference to `SDL_Flip'
sdl_ex.o: In function `main':
sdl_ex.c:(.text+0x1d5): undefined reference to `SDL_Init'
sdl_ex.c:(.text+0x209): undefined reference to `SDL_SetVideoMode'
sdl_ex.c:(.text+0x217): undefined reference to `SDL_Quit'
sdl_ex.c:(.text+0x269): undefined reference to `SDL_PollEvent'
sdl_ex.c:(.text+0x278): undefined reference to `SDL_Quit'
collect2: ld returned 1 exit status
make: *** [sdl_ex] Error 1

What am I doing wrong?

Thanks in advance!
 
In the first case the command, look in the lib directory if you have libSDL.a, the static library. Some toolchain not have the static library, but you can use the dynamic version using `${TOOLCHAIN}/bin/sdl-config --libs` or -dynamic option in the compiler.

In the second case, the makefile I think you need to pass the include and libs variables to the compiler in this way. The errors that you see are link errors, because the compiler can't find the SDL library. This can be solved with the LDFLAGS.

Code:
sdl_ex: sdl_ex.o
        cc sdl_ex.o $(LDFLAGS) -o sdl_ex.gpe.wiz
sdl_ex.o: sdl_ex.c
         cc -c sdl_ex.c -I$(INCS)
 
Hardyx said:
In the first case the command, look in the lib directory if you have libSDL.a, the static library. Some toolchain not have the static library, but you can use the dynamic version using `${TOOLCHAIN}/bin/sdl-config --libs` or -dynamic option in the compiler.

In the second case, the makefile I think you need to pass the include and libs variables to the compiler in this way. The errors that you see are link errors, because the compiler can't find the SDL library. This can be solved with the LDFLAGS.

Code:
sdl_ex: sdl_ex.o
        cc sdl_ex.o $(LDFLAGS) -o sdl_ex.gpe.wiz
sdl_ex.o: sdl_ex.c
         cc -c sdl_ex.c -I$(INCS)

Ok so I think that worked:

My Makefile:
Code:
TOOLCH = /opt/openwiz/toolchain/arm-openwiz-linux-gnu
  CC     = ${TOOLCH}/bin/arm-openwiz-linux-gnu-gcc
  CXX    = ${TOOLCH}/bin/arm-openwiz-linux-gnu-g++
  INCS   = -I${TOOLCH}/include -I${TOOLCH}/include/SDL
  LD     = ${TOOLCH}/bin/arm-openwiz-linux-gnu-g++
  LDFLAGS= -L${TOOLCH}/lib -lSDL -lm -ldl -lpthread -lz

sdl_ex: sdl_ex.o
        cc sdl_ex.o ${LDFLAGS} -o sdl_ex.gpe.wiz
sdl_ex.o:
        cc -c sdl_ex.c -I${INCS}

$ make
cc sdl_ex.o -L/opt/openwiz/toolchain/arm-openwiz-linux-gnu/lib -lSDL -lm -ldl -lpthread -lz -o sdl_ex.gpe.wiz
/usr/bin/ld: skipping incompatible /opt/openwiz/toolchain/arm-openwiz-linux-gnu/lib/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: skipping incompatible /opt/openwiz/toolchain/arm-openwiz-linux-gnu/lib/libgcc_s.so when searching for -lgcc_s

It did compile with make not sure why the warnings, isn't it using the wrong ld? Still not sure why the path in the error is /usr/bin/ld.
If I'm thinking correctly it looks like it may not have used the arm compiler?
Either way I don't have my Wiz on me currently but when I get home i'll test the gpe file and see if this works, i'll update this thread.

Thanks!
 
Last edited by a moderator:
I think you are using the Linux (intel) compiler and linker too.
You have the variables CC and LD to call the correct commands, to compile for ARM.

Use this in your Makefile:
${LD} sdl_ex.o $(LDFLAGS) -o sdl_ex.gpe.wiz

${CC} -c sdl_ex.c -I${INCS}
 
I think we're closer:

Code:
TOOLCH = /opt/openwiz/toolchain/arm-openwiz-linux-gnu
CC     = ${TOOLCH}/bin/gcc
CXX    = ${TOOLCH}/bin/g++
INCS   = -I${TOOLCH}/include -I${TOOLCH}/include/SDL
LD     = ${TOOLCH}/bin/gcc
LDFLAGS= -L${TOOLCH}/lib -lSDL -lm -ldl -lpthread -lz

sdl_ex: sdl_ex.o
        ${LD} sdl_ex.o ${LDFLAGS} -o sdl_ex.gpe.wiz
sdl_ex.o:
        ${CC} -c sdl_ex.c -I${INCS}

Err I'm feeling like a noob lol:

$ make
/opt/openwiz/toolchain/arm-openwiz-linux-gnu/bin/gcc sdl_ex.o -L/opt/openwiz/toolchain/arm-openwiz-linux-gnu/lib -lSDL -lm -ldl -lpthread -lz -o sdl_ex.gpe.wiz
ld: this linker was not configured to use sysroots
make: *** [sdl_ex] Error 1

Thanks in advance!
 
Use this settings in your makefile. The compiler commands are prefixed with the name of the host system:

Code:
TOOLCH = /opt/openwiz/toolchain/arm-openwiz-linux-gnu
CC     = ${TOOLCH}/bin/arm-openwiz-linux-gnu-gcc
LD      = ${TOOLCH}/bin/arm-openwiz-linux-gnu-gcc
 
Back
Top