Compiling with mingw32 (gcc-2.95.2)

Hi !

I have some problems compiling SDL programs with mingw32. Do I have to set
some compiler options or stuff (like in linux with the -lpthread -L/usr/lib
-lSDL) ???

Ahh…and does anyone on this list use Dev-C++ for developing ? I have some
questions about including SDL with this IDE…

Looking forward for you answers :)–
Sascha G?nther
(@Sascha_Gunther)

LINUX - Power for nothing and bits for free…

Got it now

Ahh…and does anyone on this list use Dev-C++ for developing ? I have some
questions about including SDL with this IDE…

If someone uses Dev-C++ and is not sure : copy the SDL-Development-runtime
files to your Dev-C+±-root-directory and add -lSDL to project options/linker
options.

Great…now it works under Linux and Windows…and I can play –
Sascha G?nther
(@Sascha_Gunther)

LINUX - Power for nothing and bits for free…

Sascha G?nther wrote:

Hi !

I have some problems compiling SDL programs with mingw32. Do I have to set
some compiler options or stuff (like in linux with the -lpthread -L/usr/lib
-lSDL) ???

my gcc version: gcc version 2.95.2 19991024

I resolved the problem by:

th Makefile:
CROSS-PATH=/usr/local/cross-tools/i386-mingw32msvc/bin/
xwin32:
$(CROSS-PATH)gcc main.c -lSDL -o prog.exe
NOTE: the source has to be placed BEFORE any other option(WHY?)

the code:
#ifdef _WIN32
int WinMain(int argc, char * argv[]){
#else ifdef _LINUX
int main (int argc,char *argv[]){
#endif

in this way i’ve been able to compile my code with the cross compiler

Hi !

I have some problems compiling SDL programs with mingw32. Do I have to set
some compiler options or stuff (like in linux with the -lpthread -L/usr/lib
-lSDL) ???

Link with the output of sdl-config --libs from the cross-compile bin directory.

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

the code:
#ifdef _WIN32
int WinMain(int argc, char * argv[]){
#else ifdef _LINUX
int main (int argc,char *argv[]){
#endif

You should not do this. SDL has it’s own main for Win32 which performs
some initialization necessary to get DirectInput keyboard input. Just
#include “SDL.h” in the file containing main(), and declare main like
this:

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

in this way i’ve been able to compile my code with the cross compiler

There are also some really handy cross-build scripts on the Xmingw32 page:
http://www.libsdl.org/Xmingw32/

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software