SDL Development in Windows with MinGw
This is OLD content
Downloads
Download the latest SDL development libraries (as of this writing, version 1.2.3)
- http://www.libsdl.org/download-1.2.php
- unzip into c:\SDL-1.2.3 or similar
- Copy c:\SDL-1.2.3\i386-mingw32msvc\lib\SDL.dll into the directory where you will develop your application.
Download MinGw
- http://www.mingw.org/
- Unzip into c:\mingw or similar
- Add c:\mingw\bin to your path.
- In WinXP or Win2k, go to the properties of My Computer, click on the Advanced tab, click on Environment Variables. Click New under User variables (or system if you want this to work for all users). Enter path and c:\mingw\bin.
- In Win95, Win98 or WinME, run notepad, open c:\autoexec.bat and at the bottom, add the line set PATH="C:\mingw\bin;%PATH%"
Install an editor
Even notepad will work, but I my personal favorite is SciTe. Completely free and very useful. Available for Windows and Linux. http://www.scintilla.org/SciTEDownload.html
Start your project
Create a .c or .cpp file for your project. I suggest downloading a test or example file to begin with.
Create a Makefile file for your project. The following three lines will be adequate (there are tabs before the 2nd and 3rd lines) (use sdl-config if developing in Linux. I have had troubles getting it to work well in Windows. The commands below should work, though) all:
gcc -Ic:/SDL-1.2.3/i386-mingw32msvc/include/SDL -c myproject.cpp gcc -Lc:/SDL-1.2.3/i386-mingw32msvc/lib myproject.o -o myproject -lmingw32 -lSDLmain -mwindows -lSDL
Note If you are going to use OpenGL, add -lglu32 -lopengl32 to the end of the last line in the Makefile. You may need to add -Ic:/path/to/opengl/headers after gcc in the 2nd line
To compile your program, simply open a command prompt, cd to the directory of your project and type make. If you are using SciTe, you can press F7 to run a "make" and F5 to execute the application.
Note Any output to stdout (the console) is redirected to stdout.txt. Similarly for stderr.
Use the SDL documentation while developing: c:\SDL-1.2.3\docs\html\index.html