Compiling an SDL app with migw32

hi,

I’ve made some little programs using SDL on linux and now I want to compile
them on windows.
I have the pre-compiled SDL libs and , with migw32, the compilation finishes
without errors. But when I launch the program, whichever it is, I get a
little quick window to pop up with a message I can’t even read and the
application crashes.

I must say that, not used to compiling win32 apps, I copied the following
line instead of the traditional “int main(int argc,char *argv[])” :

int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine,
int nCmdShow )

I also added “#include <windows.h>”

And, finally, I compile it using “gcc -o test test.c -lSDL -mwindows”.

I’m sure I made lots of errors so if you know how to help me, your help is
welcome !

Thanks by advance…

I must say that, not used to compiling win32 apps, I copied the following
line instead of the traditional “int main(int argc,char *argv[])” :

In my little test app I had to use 'int main(int argc, char *argv[])'
though I don’t remember if that was just to get it to compile
or if it compiled and didnt run under win32. It was a few weeks
ago.

Compiles for both now.
http://www.hal-pc.org/~acjr/sdl/SDL_rand.tar.gzOn Mon, 4 Sep 2000 09:50:39 +0200, Julien Olivier wrote:

Yes, you use plain int main(…), but you need to link it to SDLmain
(-lSDLmain. This provides WinMain). There are some nice build scripts on
www.libsdl.org/Xmingw32/ for use with autoconf. Hope this helps.

-ArthurFrom: acjr@hal-pc.org (Arturo C)
Subject: [SDL] Re: compiling an SDL app with migw32
Date: 4 Sep 2000 18:49:04 GMT

On Mon, 4 Sep 2000 09:50:39 +0200, Julien Olivier wrote:

I must say that, not used to compiling win32 apps, I copied the following
line instead of the traditional “int main(int argc,char *argv[])” :

In my little test app I had to use 'int main(int argc, char *argv[])'
though I don’t remember if that was just to get it to compile
or if it compiled and didnt run under win32. It was a few weeks
ago.

Yes, you use plain int main(…), but you need to link it to SDLmain
(-lSDLmain. This provides WinMain). There are some nice build scripts on
www.libsdl.org/Xmingw32/ for use with autoconf. Hope this helps.

In my little test app I had to use 'int main(int argc, char *argv[])'
though I don’t remember if that was just to get it to compile
or if it compiled and didnt run under win32. It was a few weeks
ago.

Well I develop under linux, and sometimes compile a win32 binary,…
so I don’t really use dependencies for the win32 compile
the main function is the same in linux and window:

int main (int argc, char *argv[])

I use the following hacked up makefile:

all: voxel server voxel.exe
voxel: voxel.o main.o data.o gfx.o packet.o net.o menu.o descriptor.o
gcc -o voxel voxel.o main.o menu.o data.o gfx.o packet.o net.o
some.o descriptor.o action.o sdl-config --libs
gcc $(C_FLAGS) -c some.o


clean:
rm -rf *~ gfx/ *.o core *.core voxel voxel.exe server DEADJOE
voxel.exe: clean voxel.c main.c gfx.c data.c gfx.h data.h
export PATH=/usr/local/cross-tools/i386-mingw32/bin:/usr/local/cross-tools/bin:$PATH;
gcc sdl-config --cflags -c *.c;
gcc sdl-config --cflags -o voxel.exe *.o sdl-config --libs;
strip voxel.exe;On Mon, 4 Sep 2000, Arthur Peters wrote:

.------------------------
| .~. check my latest project
| /V\ open minds, hierarchical notebook
| // \ open source, http://hnb.sourceforge.net/
| /( )\ open future
^~’^

…is not implemented as far as I understood the source.

Well, I assume that with the so called Multiprocessing Library (MP
Library ) even preemptive threads may be created on the macOS.

So I started to implement the SDL_sysmutex.c SDL_syssem.c
SDL_systhread.c and SDL_systhread_c.h(:slight_smile: ) using the Multiprocessing
API which worked quite well. The only problem I encountered when
compiling the testthread target from the SDLTest project was calling
the SDL_Delay() function which resulted in the threads
termination(arrgh).

I figured out that the termination always took place when I tried to
call any timer specific functions from within the thread function. But
no problems occured with printf.

I did not test it through and through, but perhaps someone would be
interested in the sourcecode ? Darrell ?

Sven.

…is not implemented as far as I understood the source.

Well, I assume that with the so called Multiprocessing Library (MP
Library ) even preemptive threads may be created on the macOS.

So I started to implement the SDL_sysmutex.c SDL_syssem.c
SDL_systhread.c and SDL_systhread_c.h(:slight_smile: ) using the Multiprocessing
API which worked quite well. The only problem I encountered when
compiling the testthread target from the SDLTest project was calling
the SDL_Delay() function which resulted in the threads
termination(arrgh).

I figured out that the termination always took place when I tried to
call any timer specific functions from within the thread function. But
no problems occured with printf.

I did not test it through and through, but perhaps someone would be
interested in the sourcecode ? Darrell ?

Sounds interesting. I always wondered if this was possible, but since I
don’t have a dual-CPU Mac…

It’s odd how timer routines don’t work anymore. Does the SDL_Delay() you are
using still use the old Delay() toolbox call?

I don’t know much about MP Library, are some Toolbox calls not thread safe?

Can you send me your code? If it also works on a single-CPU Mac, we might
be able to finally port SMPEG library (I already have it built, but It
doesn’t work due to lack of thread support).> From: Sven Schaefer

Reply-To: sdl at lokigames.com
Date: Tue, 5 Sep 2000 13:34:42 +0200 (MET DST)
To: sdl at lokigames.com
Subject: [SDL] MacOS: Using threads…