To get up and running with a command-line, make driven build system we will first have to compile and install the latest SDL library. Open up the cygwin shell. You are placed in your home directory. To paste commands into the cygwin shell right-click anywhere in the window and then go to Edit -> Paste.
The latest version of Cygwin is 1.7.x and the default compiler is gcc version 4. At the time of this writing this compiler could not successfully compile SDL in this environment. If you have this version of Cygwin the default compiler will have to be switched to version 3 and can be done as follows
$ chmod 755 /usr/bin/set-gcc-default-3.sh $ /usr/bin/set-gcc-default-3.sh
if you need to switch back
$ chmod 755 /usr/bin/set-gcc-default-4.sh $ /usr/bin/set-gcc-default-4.sh
The chmod command only has to be run once to make the file executable.
To verify what version of gcc is set as the default run
$ gcc --version
Before compiling SDL there are some DirectX headers and libs that should be downloaded and put into the correct locations. On my cygwin install the headers where already there but the libs were not. They aren’t needed for compilation but without them the dsound audio back end will not be available when running a program from the command line.
$ wget http://www.libsdl.org/extras/win32/cygwin/directx-devel.tar.gz $ tar zxvf directx-devel.tar.gz $ rsync -av include/w32api/ /usr/include/w32api/ $ rsync -av lib/w32api/ /usr/lib/w32api/
Download the latest SDL.
$ wget http://www.libsdl.org/release/SDL-1.2.15.tar.gz
Decompress, and build.
$ tar zxvf SDL-1.2.15.tar.gz $ cd SDL-1.2.15 $ ./configure && make && make install
Next we will setup the rest of the build system but we won’t have to build the rest of the libs from source, we can just use the compiled libs, dlls, and headers from the SDL projects section. http://www.libsdl.org/projects/
Double click one of the downloaded zips and it should open in Windows Explorer. Open another file manager window and navigate to the main cygwin directory — C:\cygwin if you went with the default during the install.
What you see here are the directories that correspond to typing ‘ls /’ in the cygwin shell.
By default the SDL compilation and install process installed into
/usr/local
which corresponds to
C:\cygwin\usr\local
this is where we will copy the other needed files.
Copy all .lib files to C:\cygwin\usr\local\lib.
Copy all .dll files to C:\cygwin\usr\local\bin.
Copy all .h files to C:\cygwin\usr\local\include.
Next we will need to install the boost C++ libraries.
Note: boost 1.47 or a lesser version must be used here as some changes in later versions are not compiling with gcc 3 which is needed to compile SDL under Cygwin as previously explained.
Download the boost zip archive and copy the
boost_1_47_0.zip\boost_1_47_0\boost
folder to
C:\cygwin\usr\local\include
When you are finished copying all the files you may want to verify that you’ve copied them all to the correct locations. You can check the listings using the cygwin shell.
$ cd /usr/local/ ย $ ls bin SDL.dll SDL_mixer.dll jpeg.dll libogg-0.dll libtiff-3.dll libvorbisfile-3.dll zlib1.dll SDL_image.dll SDL_ttf.dll libfreetype-6.dll libpng12-0.dll libvorbis-0.dll sdl-config ย $ ls include SDL SDL_image.h SDL_mixer.h SDL_ttf.h boost ย $ ls lib SDL_image.lib SDL_mixer.lib SDL_ttf.lib libSDL.a libSDL.dll.a libSDL.la libSDLmain.a pkgconfig
That’s everything needed to build the Classic Invaders source (2 MB).
Decompress the source archive, cd into the source directory, and type
$ ./configure --datadir=c:/cygwin/usr/local/share $ make $ make install
then run
$ classic_invaders.exe