Help - Search - Members - Calendar
Full Version: Sdl/zgcc Problem - Please Help
OESF Portables Forum > Everything Else > Archived Forums > Distros, Development, and Model Specific Forums > Zaurus - Everything Development > Linux Applications
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
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:

OPTIMIZE=" -O3 -fexpensive-optimizations -funroll-loops -fomit-frame-pointer "
./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:
SDLLIB=-lqte -lqpe -lSDLmain -lSDL -L/mnt/cf/.zgcc/lib -lm -lc /lib/
#note: funky link to pthread above is due to missing symlink in /lib
SDLINC=-D_REENTRANT -I/mnt/cf/.include/Qtopia

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) ;-)


Any suggestions folks? I'm stuck at this point.


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

#ifdef __cplusplus
extern "C"
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.)
Thanks mate. That fixed the problem!


ps: Noticed you're from Sydney. Is there much of a Zaurus community there?
How hard is it to buy a Z? Just curious.
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 smile.gif

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! (my choice) or one of the other international Z retailers is definitely still the way to go.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.