Mingw32 compile with SDL

How do i compile SDL with mingw32.

I can compile a cpp file only using mingw32 but now i have added the SDL
and i did follow the install instructions.

this is how i compile without SDL

gcc kurt.cpp -o kurt.exe

should there be a -lSDL after it ?
or something with the SDL.dll ?

/GooFu

How do i compile SDL with mingw32.

I can compile a cpp file only using mingw32 but now i have added the SDL
and i did follow the install instructions.

this is how i compile without SDL

gcc kurt.cpp -o kurt.exe

should there be a -lSDL after it ?
or something with the SDL.dll ?

Link the output of sdl-config --libs
On my Mingw32 setup:
-lmingw32 -lSDLmain -lSDL -mwindow

Also use the output of “sdl-config --cflags” when compiling the source.

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

I?m new on this, I?m only a game designer and i need something to play around
with, so I decided to try SDL. I have little knowledge in setting up stuff
like this. (sorry)

Should i write:
gcc kurt.cpp -o kurt.exe -lmingw32 -lSDLmain -lSDL -mwindow ?

and the    sdl-config --cflags     should it be there to ?

Sorry I?m a new on this.

Sam Lantinga wrote:> > How do i compile SDL with mingw32.

I can compile a cpp file only using mingw32 but now i have added the SDL
and i did follow the install instructions.

this is how i compile without SDL

gcc kurt.cpp -o kurt.exe

should there be a -lSDL after it ?
or something with the SDL.dll ?

Link the output of sdl-config --libs
On my Mingw32 setup:
-lmingw32 -lSDLmain -lSDL -mwindow

Also use the output of “sdl-config --cflags” when compiling the source.

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

Should i write:
gcc kurt.cpp -o kurt.exe -lmingw32 -lSDLmain -lSDL -mwindow ?

write:
gcc kurt.cpp -o kurt.exe $(sdl-config --cflags --libs)

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

write:
gcc kurt.cpp -o kurt.exe $(sdl-config --cflags --libs)

gcc kurt.cpp -o kurt.exe $(shell sdl-config --cflags --libs)

write:
gcc kurt.cpp -o kurt.exe $(sdl-config --cflags --libs)

gcc kurt.cpp -o kurt.exe $(shell sdl-config --cflags --libs)

It depends whether or not you have this inside a Makefile or not.

Inside a Makefile:

kurt.exe:
gcc kurt.cpp -o kurt.exe $(shell sdl-config --cflags --libs)

From the command line:
gcc kurt.cpp -o kurt.exe $(sdl-config --cflags --libs)

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

From the command line:
gcc kurt.cpp -o kurt.exe $(sdl-config --cflags --libs)

No, use backquotes here. $() is a bash-ism.

$ echo $(pwd)
syntax error: (' unexpected $ echopwd`
/home/mattias

Nothing works :frowning:

This is what I have done, I’m using WIN 98

Unpacked mingw32.zip to C:\gcc-2.95.2

I can compile a *.cpp with
gcc kurt.cpp -o a.exe

Then:

Unpacked the i386-mingw32msvc.tar.gz file in
C:\gcc-2.95.2 , Copy SDL.dll from i386-mingw32msvc/lib/ and include it
with your
application, in the directory where your executable resides.

This is in my Autoexec.bat
set PATH=c:\gcc-2.95.2\bin;%PATH%

Errors when i?m try:
gcc kurt.cpp -o kurt.exe $(sdl-config --cflags --libs)

GCC.EXE: $: no such file or directory
GCC.EXE: (sld-config: no such file or directory
cc1plus.exe: Invlid option -fclags
cc1plus.exe: Invlid option -flibs

/GrooFu

Sam Lantinga wrote:> > Should i write:

gcc kurt.cpp -o kurt.exe -lmingw32 -lSDLmain -lSDL -mwindow ?

write:
gcc kurt.cpp -o kurt.exe $(sdl-config --cflags --libs)

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

Nothing works :frowning:

This is what I have done, I’m using WIN 98

Unpacked mingw32.zip to C:\gcc-2.95.2

This is in my Autoexec.bat
set PATH=c:\gcc-2.95.2\bin;%PATH%

I can compile a *.cpp with
gcc kurt.cpp -o a.exe

Then:

Unpacked the i386-mingw32msvc.tar.gz file in
C:\gcc-2.95.2 , Copy SDL.dll from i386-mingw32msvc/lib/ and include it
with your
application, in the directory where your executable resides.

Errors when i?m try gcc kurt.cpp -o kurt.exe $(sdl-config --cflags
–libs) :

GCC.EXE: $: no such file or directory
GCC.EXE: (sld-config: no such file or directory
cc1plus.exe: Invlid option -fclags
cc1plus.exe: Invlid option -flibs

/GrooFu

Sam Lantinga wrote:> > >write:

gcc kurt.cpp -o kurt.exe $(sdl-config --cflags --libs)

gcc kurt.cpp -o kurt.exe $(shell sdl-config --cflags --libs)

It depends whether or not you have this inside a Makefile or not.

Inside a Makefile:

kurt.exe:
gcc kurt.cpp -o kurt.exe $(shell sdl-config --cflags --libs)

From the command line:
gcc kurt.cpp -o kurt.exe $(sdl-config --cflags --libs)

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

GrooFu wrote:

Errors when i?m try gcc kurt.cpp -o kurt.exe $(sdl-config --cflags
–libs) :

GCC.EXE: $: no such file or directory
GCC.EXE: (sld-config: no such file or directory
cc1plus.exe: Invlid option -fclags
cc1plus.exe: Invlid option -flibs

/GrooFu

Are you using the DOS shell to enter the above line or the cygnus port of
bash? DOS won;t understand the $(…) construct (and actually a lot of
other shells won;t either - i got attacked for doing it like that on this
mailing list in the past. the prefered way it to use ...)

    -- David Snopek

Nothing yet

Im in a DOS window.

This time i wrote:
gcc kurt.cpp -o kurt.exe sdl-config --cflags --libs

Errors:
GCC.EXE: `sdl-config: No such file or directory.
Kurt.cpp:5: SDL.h: No such file or directory.

This id the path to sdl-config:
C:\gcc-2.95.2\i386-mingw32msvc\bin\sdl-config

Please help me , what am I doing wrong, aarrrggghhhhh
(I will not give up :slight_smile: )

/GrooFu>

GrooFu wrote:

Nothing yet

Im in a DOS window.

This time i wrote:
gcc kurt.cpp -o kurt.exe sdl-config --cflags --libs

Errors:
GCC.EXE: `sdl-config: No such file or directory.
Kurt.cpp:5: SDL.h: No such file or directory.

This id the path to sdl-config:
C:\gcc-2.95.2\i386-mingw32msvc\bin\sdl-config

You have to understand that the DOS shell is weak. It doesn;t
understand the sdl-config syntax. You should download the cygnus port
of bash.

    -- David Snopek

Nothing yet

Im in a DOS window.

Ahh, there’s your problem. You need to run the mingw32.bat file that
is included in the gcc-2.95.2 directory that you get when you unpack
the mingw32 tools available from: http://www.libsdl.org/Xmingw32/

This will launch the bash shell which is similar to, but not exactly
the same as the DOS shell. The biggest difference you’ll see immediately
is that you must use ‘/’ instead of ‘’ as the directory separator.

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

Aha Something happend, and now i got a new Error :?(

In function

console_main':/home/hercules/SDL-dist/SDl-1.1.6)src/main/SDL_main.c:171: Undefined reference toSDL_main`

/GrooFu

Aha Something happend, and now i got a new Error :?(

In function

console_main':/home/hercules/SDL-dist/SDl-1.1.6)src/main/SDL_main.c:171: Undefined reference toSDL_main`

Much better. :slight_smile:

Check the FAQ:
http://www.libsdl.org/faq/FAQ-Win32.html#WIN32_8

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

YEEESSSS

It works :slight_smile:

But i have to use
#include <SDL/SDL.h>

/GrooFu