OESF Portables Forum

Everything Else => Zaurus - Everything Development => Distros, Development, and Model Specific Forums => Archived Forums => Linux Applications => Topic started by: fordprefect on April 17, 2005, 01:33:08 pm

Title: Sdl/zgcc Problem - Please Help
Post by: fordprefect on April 17, 2005, 01:33:08 pm
Hi All,

I'd like to port some SDL apps and develop directly on the Zaurus, but I'm stuck
at a critical step here. Any pointers you can give me would be appreciated.

I'm an experienced C coder, but not so experienced with SDL, or development on the Z.

I'm trying to get an SDL program I wrote working on the Z (I have a C860) via
onboard development - Not using a cross compiler, but building using zgcc 2.95-2
on the stock Sharp ROM.

The program compiles and runs just fine on a PC, but dies on the Zaurus with the infamous:
--
QPaintDevice: Must construct a QApplication before a QPaintDevice
Aborted
--
I've read that this error is often due to a missing link to libSDLmain.a, but I'm linking to
it already!

I built my own SDL using the CVS version of the zports SDL.
Since the checked out zports version was missing some files,
I merged it with a vanilla copy of SDL 1.2.8 - hopefully that isn't
causing some funkiness (I assume it isn't since my compiled version
of SDL doesn't seem to crash my existing SDL programs).

Here are the build options I used to compile SDL onboard:

#!/bin/bash
OPTIMIZE=" -O3 -fexpensive-optimizations -funroll-loops -fomit-frame-pointer "
export CFLAGS="$OPTIMIZE -DZAURUS_SL=1"
./configure --enable-video-qtopia --disable-video-dummy --disable-video-fbcon  -
-disable-video-dga --disable-arts --disable-esd --disable-alsa --disable-video-x
11 --disable-nasm --prefix=/opt/QtPalmtop


Here's the relevant part of the Makefile for my program:
--
CFLAGS=-Wall -g ${SDLINC}
SDLLIB=-lqte -lqpe -lSDLmain -lSDL -L/mnt/cf/.zgcc/lib -lm -lc /lib/libpthread.so.0
#note: funky link to pthread above is due to missing symlink in /lib
SDLINC=-D_REENTRANT -I/mnt/cf/.include/Qtopia
CC=$(GCCPREFIX)gcc ${CFLAGS}

foo: foo.o ${OBJ}
        ${CC} ${CFLAGS} foo.o ${OBJ} -o foo ${SDLLIB}

--

Any help would be greatly appreciated - I hope I'm just missing something
obvious (Wouldn't be the first time) ;-)

Thanks,

Ford
Title: Sdl/zgcc Problem - Please Help
Post by: fordprefect on May 01, 2005, 11:01:04 am
Any suggestions folks? I'm stuck at this point.

cheers,

Ford
Title: Sdl/zgcc Problem - Please Help
Post by: pelrun on May 18, 2005, 03:07:59 am
I just hit this issue myself, and I eventually figured it out. Apparently the correct way to  fix this is:

1) add #include "SDL_main.h" to the source file with your main() function
2) change your main() function definition to

Code: [Select]
#ifdef __cplusplus
extern "C"
#endif
int main(int argc, char *argv[])
3) ensure -DQWS is in the options to the compiler. If the sdl-config script is being called, add it to the --cflags section.
4) link with libSDLmain as you're already doing.

This should then do the right thing regardless of the platform being compiled for.

What is happening is that libSDLmain defines it's own main() function with the extra initialisation some platforms (Qtopia, win32, macosx etc) need. It then jumps to the symbol SDL_main, which is the original application's main() function. The SDL_main.h header file will redefine main to SDL_main if needed (in this case, because QWS is defined.)
Title: Sdl/zgcc Problem - Please Help
Post by: fordprefect on May 24, 2005, 10:26:53 am
Thanks mate. That fixed the problem!

Cheers,

Ford
ps: Noticed you're from Sydney. Is there much of a Zaurus community there?
How hard is it to buy a Z? Just curious.
Title: Sdl/zgcc Problem - Please Help
Post by: pelrun on May 25, 2005, 12:32:33 am
Good to hear it's working for you now - it's definitely something that should be documented a little better than it is.

Ouch... I should really change my location - I moved to Brisbane a few months ago  

Haven't seen much of a Z community in Sydney (I wasn't looking too hard) but there are definitely a few people posting to the Sydney and Brisbane regional boards here. I definitely wouldn't try buying a Z locally though! The one retailer I've seen selling C3000's is putting a 70% markup on them! Pricejapan.com (my choice) or one of the other international Z retailers is definitely still the way to go.