Compiling ASC for Windows
Introduction
To summarize this whole tutorial: software development for Windows simply sucks. It's a pain in the ass. If you want to enjoy developing software, go to Linux.
But unfortunately, there are still lots of users out there who want to player ASC - and we can't deprive them of ASC, can we? So I put together this document in the hope that maybe someone apart from me will manage to compile ASC...
If you want to give it a try, please make sure you have
- plenty of time
- plenty of free hard disk capacity (5 GB should be sufficient)
- plenty of bandwidth
- plenty of patience
General principals
Library location publishing
ASC uses two different mechanisms to locate libraries it needs. Libraries need two kinds of directoriese to be made known to the application that uses the library:
- the INCLUDE directory with the header files
- the LIB directory with the compiled libraries against which the application is linked.
In some cases the ASC project references an environment variable that has to be set to the library directory. For other libs the installation directory must be registered in the global VisualStudio directories, so that VisualStudio automatically searches that directory for files. This is done in Tools -> Options ->Projects & Solutions / VC++ Directories / Include Files or Library Files, respectively.
The environment variable system is usually used when
- different projects may need different versions of a library
- debug and release library names have the same name, but are located in different directories
- the had been the need to debug the libraries during ASC development
Directory names
It usually does not matter where you install your libraries. In this tutorial, I'm using fixed directories so that I can easily reference them.
In this article I assume that we are installing all stuff into a folder ascdev. It may be c:\program files\ascdev , it may be somewhere else. It doesn't matter. Whenever the directory ascdev is mentioned, please use the fully qualified path, like c:\program files\ascdev
Several directory names contain version numbers. If you are downloading newer versions of the libraries, you may of course adjust the version numbers accordingly.
Setting up the IDE
Get and Install Microsoft Visual C++ Express
Download the DirectX SDK from Microsoft
Install it into ascdev\directX-sdk
Setting up the libraries
Setup DLL target dir
Create a directory ascdev\dlls where all created dlls will be placed
- Add this directory to Windows' path environment variable
Boost
Download Boost installer from http://www.boostpro.com/products/free (this includes the precompiled libs for MSVC, which the official distribution from http://www.boost.org lacks)
Install everything (you may skip the single-threaded libs) into ascdev\boost_1_35_0
In Visual Studio, set ascdev\boost_1_35_0 as global include directory ...
- ... and 'ascdev\boost_1_35_0\lib' as global library dirctory.
SDL
- Download SDL 1.2 from [www.libsdl.org]
Unzip the archive into ascdev (which will result in a directory ascdev\SDL-1.2.13)
Unzip ascdev\SDL-1.2.13\VisualC.zip into the ascdev\SDL-1.2.13 directory (which result in a directory ascdev\SDL-1.2.13\VisualC)
Open ascdev\SDL-1.2.13\VisualC\SDL.sln in Visual Studio
Build everything ( Build -> Batch Build -> Select All )
Go to Tools -> Options ->Projects & Solutions / VC++ Directories / Include Files and add the ascdev\SDL-1.2.13\include directory there.
In the same dialog, add ascdev\SDL-1.2.13\VisualC\SDL\Release and ascdev\SDL-1.2.13\VisualC\SDLmain\Release_NOSTDIO to the library directories
Copy ascdev\SDL-1.2.13\VisualC\SDL\Release\SDL.dll into ascdev\dlls
In Windows, go to Control Panel -> System -> Advanced -> Environment Variables and add a variable SDL with the value ascdev\SDL-1.2.13\VisualC\SDL (this is to provide the paths to the libraries. We are not doing this through a setting in Visual Studio because we want to access the release build and debug builds individually, which both have the same name)
SDL-mixer
Download SDL-Mixer from http://www.libsdl.org/projects/SDL_mixer/
Unzip it into the ascdev Folder (which will result in a directory ascdev\SDL_mixer-1.2.8)
Unzip ascdev\SDL_mixer-1.2.8\VisualC.zip into the ascdev\SDL_mixer-1.2.8 directory (which will result in a directory ascdev\SDL_mixer-1.2.8\VisualC)
Open ascdev\SDL_mixer-1.2.8\VisualC\SDL_mixer.sln in Visual Studio
Build everything ( Build -> Batch Build -> Select All )
There will be a few errors because the file afxres.h is not found. Replace afxres.h by winresrc.h in the source file
- Build again everything
copy ascdev\SDL_mixer-1.2.8\VisualC\Release\SDL_mixer.dll into ascdev\dlls
add ascdev\SDL_mixer-1.2.8 to Visual C++ include dir
add ascdev\SDL_mixer-1.2.8\VisualC\Release to Visual C++ library dir
SDL-Image
Download SDL-Image from http://www.libsdl.org/projects/SDL_image/
Unzip it into the ascdev Folder (which will result in a directory ascdev\SDL_image-1.2.6)
Unzip ascdev\SDL_image-1.2.6\VisualC.zip into the ascdev\SDL_image-1.2.6 directory (which will result in a directory ascdev\SDL_image-1.2.6\VisualC)
Open ascdev\SDL_image-1.2.6\VisualC\SDL_image.sln in Visual Studio
Build everything ( Build -> Batch Build -> Select All )
There will be a few errors because the file afxres.h is not found. Replace afxres.h by winresrc.h in the source file
- Build again everything
Add ascdev\SDL_image-1.2.6 to Visual Studio include dir
Add ascdev\SDL_image-1.2.6\VisualC\Release to Visual Studio library dir
copy ascdev\SDL_image-1.2.6\VisualC\Release\SDL_image.dll into ascdev\dlls\
copy the following files from ascdev\SDL_image-1.2.6\VisualC\graphics\lib to ascdev\dlls :
jpeg.dll
libpng12-0.dll
libtiff-3.dll
SMPEG
To get the SMPEG sources, you need the Subversion client. If you don't have it, download it from http://subversion.tigris.org
Go to the ascdev directory and run svn co svn://svn.icculus.org/smpeg/trunk smpeg (which will create a directory ascdev\smpeg)
In VisualStudio, add ascdev\smpeg to the global include dirs (see SDL section)
Unzip the VisualC.zip
Open ascdev\smpeg\VisualC\smpeg.dsw
- Build the smpeg library for both debug and release
Add ascdev\smpeg\VisualC\Release to Visual Studio library dir
copy ascdev\smpeg\VisualC\Release\smpeg.dll into ascdev\dlls\
LibOgg, LibVorbis
Download libogg, libFlac and libvorbis from http://xiph.org/ and extract them
LibOgg and LibVorbis have each a win32 subdirectory with a .dsw file in. Open it in Visual Studio and build all targets.
- For Libflac it's in the main directory. Build it too.
Add ascdev\libvorbis-1.2.0\include and ascdev\libogg-1.1.3\include to Visual Studio include dir.
Add ascdev\libvorbis-1.2.0\win32\Vorbis_Dynamic_Release, ascdev\libvorbis-1.2.0\win32\VorbisFile_Dynamic_Release and ascdev\libogg-1.1.3\win32\Dynamic_Release to Visual Studio lib dir
copy these files into ascdev\dlls\
ascdev\libvorbis-1.2.0\win32\VorbisFile_Dynamic_Release\vorbisfile.dll
ascdev\libvorbis-1.2.0\win32\Vorbis_Dynamic_Release\vorbis.dll
ascdev\libogg-1.1.3\win32\Dynamic_Release\ogg.dll
LibFlac
Download libFlac from http://xiph.org/
Libflac requires nasmw.exe to be in your path. Download the latest NASM release from http://nasm.sourceforge.net/
If it contains only a nasm.exe, rename it to nasmw.exe
- Put it into a directory that is in your windows path (or alternatively extend your path to the nasm directory)
- Build the libFLAC_dynamic and libFLAC_static projects for both release and debug
Add ascdev\flac-1.1.2\include to Visual Studio include dir.
Add ascdev\flac-1.1.2\obj\release\lib to library dir
copy ascdev\flac-1.1.2\obj\release\bin\libFLAC.dll into ascdev\dlls\
SDL-Sound
Download SDL-Sound from http://icculus.org/SDL_sound/
Unzip it into the ascdev Folder (which will result in a directory ascdev\SDL_sound-1.0.3)
Open ascdev\SDL_sound-1.0.3\VisualC\sdl_sound.dsw in Visual Studio
- We are now building SDL_sound without Mikmod and Modplug to make life a bit easer.
Right-click on sdl_sound_dll, select properties and go to configurion Properties -> C/C++ -> Preprocessor
For both Release and Debug remove the entries SOUND_SUPPORTS_MODPLUG and SOUND_SUPPORTS_MIKMOD from preprocessor definitions
- Do the same for sdl_sound_static
- Remove the mikmod.lib and modplug.lib from the referenced libraries
- Build the sdl_sound_* projects for debug and release
If it fails to compile, you may need to add the file decoders\timidity\instrum_dls.c to the project
Add ascdev\SDL_sound-1.0.3 to Visual Studio include directory
Add ascdev\SDL_sound-1.0.3\VisualC\win32lib to library directory
copy ascdev\SDL_sound-1.0.3\VisualC\win32lib\sdl_sound*.dll into ascdev\dlls\
LibSigC++
- Install LibSigC++ 1.2 (NOT 2.0, as it is not compatible to the 1.2 series)
- XXXXXXXXXXXXXX
Extract it to a directory ascdev\libsigc++
- compile and build it
Set an environment variable libsigcpp=ascdev\libsigc++
Freetype2
Get it from http://www.freetype.org and install it in ascdev\freetype2
Open the solution [ascdev\freetype-2.3.6\builds\win32\visualc\freetype.sln] and build all targets
Go to ascdev\freetype-2.3.6\objs and copy freetype236.lib to freetype.lib and freetype236_D.lib to freetype_D.lib. This is to avoid having ASC reference a specific version of Freetype.
Add ascdev\freetype-2.3.6\include as global include dir in VicualC++
Add ascdev\freetype-2.3.6\objs as global library dir in VisualC++
Expat
Get it from http://expat.sourceforge.net/
Install it into ascdev\Expat 2.0.1
Open ascdev\Expat 2.0.1\Source\expat.dsw in Visual Studio and build all targets
Add ascdev\Expat 2.0.1\Source\lib\ to Visual Studio include dir
Add ascdev\Expat 2.0.1\Source\win32\bin to Visual Studio lib dir
copy ascdev\Expat 2.0.1\Source\win32\bin\Release\libexpat.dll to ascdev\dlls\
Physfs
Install and build Physfs in ascdev\physfs-1.0.0
- Set a globabl environment variable `physfs=ascdev\physfs-1.0.0
LibPNG
Get it from http://www.libpng.org/pub/png/libpng.html and install it
Open the solution in (C:\Programme\ascdev\libpng-1.2.29\projects\visualc71\libpng.sln) and build all targets without ASM in their name. You can of course build all targets too, but the ASM targets will fail and we don't need them anyway.
Set an environment variable libpng=ascdev\libpng-1.2.29
Set a global include dir in Visual Studio to $(libpng)
Copy the following files from ascdev\libpng-1.2.29\projects\visualc71\Win32_DLL_Release\ into ascdev\dlls\
libpng13.dll
libpng13d.dll
ZLib\zlib1.dll
ZLib\zlib1d.dll
ZLib
Get it from http://www.zlib.net/ and install it (ascdev\zlib-1.2.3)
Open the project ( ascdev\zlib-1.2.3\projects\visualc6\zlib.dsw) in Visual Studio and compile all targets without ASM in their name (same as LibPNG)
Add ascdev\zlib-1.2.3 to Visual Studio's global include directory
Add ascdev\zlib-1.2.3\projects\visualc6\Win32_DLL_Releaseto Visual Sutdio's global library directory
Curl
Curl doesn't provide usable build files for Visual Studio, so I recommend downloading a prebuild Curl package: [http://my.guardpuppy.com/libcurl-7.15.1-msvc-win32-ssl-0.9.8a-zlib-1.2.3.zip]
Extract the package into ascdev\curl
Add ascdev\curl\include to the Visual Studio include dir
Add ascdev\curl\ to library dir
copy the file libcurl.dll libeay32.dll ssleay32.dll from ascdev\curl\ to ascdev\dlls\
Revel
Get it from http://revel.sourceforge.net/ (type: precompiled binaries) and install it to ascdev\revel-1.1.0-win32
Add ascdev\revel-1.1.0-win32\lib to VS library dir
Add revel-1.1.0-win32\include to VS include dir
Compiling ASC
Finally, everything should be ready to build ASC itself!
- Get the latest [Source Code], either packaged or through CVS. If you have got this far, I recommend using CVS because it's easier to incorporate update and to make diffs in case you make changes and want to have them incorporated.
If you get the source by CVS, you will end up with ascdev\games\asc. You can move the asc directory to ascdev\asc and then delete games
Open the project file ascdev\asc\source\win32\msvc\ASC.sln in Visual Studio
- Build all targets, which may take some time...
If everything went smooth, you will find the executables in ascdev\asc\source\win32\msvc\release\bin and ascdev\asc\source\win32\msvc\debug\bin respectively
Congratulations! You now have mastered the ASC build process on Windows! I would appreciate if you give some feedback in the Forum, so that we know somebody really managed it
