Difference between revisions of "Compiling ScummVM/Visual Studio"

From ScummVM :: Wiki
Jump to navigation Jump to search
(Moving the library related instructions to a separate page)
(Added a link to the new page)
Line 27: Line 27:
  
 
=== Building the libraries yourself ===
 
=== Building the libraries yourself ===
(TODO)
+
Refer to the [[Compiling_ScummVM/Visual_Studio/Compiling_Libraries|instructions for compiling the libraries yourself]]
 +
 
  
 
== Adding all libraries to Visual Studio ==
 
== Adding all libraries to Visual Studio ==

Revision as of 07:39, 2 September 2010

Compiling ScummVM with Visual Studio 2008/2010 under Windows

Compiling ScummVM under Windows is not an awfully hard task, however there are some things that don't just work out of the box

Things needed

Visual Studio 2010 or 2008

There exist several versions of Visual Studio 2010. A feature comparison can be found here

You can obtain the free Express version of Visual C++ 2010 here

Although Visual Studio 2010 or 2008 is preferred, older versions of Visual Studio may work so long as you have them updated to their latest Service Pack revisions. In fact, we suggest making sure that you always have the latest Service Packs and patches applied for these tool sets. In some cases, fixes were put into the free-to-download "Processor Pack" add-on for Visual C++. So, download the latest Service Pack and the latest Processor Pack for whatever version of Visual C++ you are using to make sure you won't run into compiler bugs that prevent the compilation of scummvm.

Precompiled libraries

To ease the whole process, a package of all the needed precompiled libraries has been created. All you need to do is:

  • Download the precompiled libraries and the latest SDL runtime library - latest version is 1.2.12 at the time this was written, you can find the latest version here. Mirrors for precompiled libraries:
  • Unzip the precompiled libraries archive maintaining directory structure
  • Run install.bat (Visual Studio 2005/2008 only)
  • You don't need to add the libraries to Visual Studio, as the installer automatically copies the necessary files in the appropriate directories of Visual Studio. Please note that this installer has only been tested with Visual Studio 2005 and 2008. If you get errors with earlier versions of Visual Studio, simply copy the directories bin, lib and include inside the directory where Visual C++ is installed. If you're not sure how to do that, check the section "Adding all libraries to Visual Studio" further on
  • Unzip sdl.dll from the SDL runtime in the same directory where the scummvm executable will be created (default is under dits\msvc9\scummvm_Release, substitute msvc9 for msvc8 if you're using Visual Studio 2005 and msvc7 if you're using Visual Studio 2003)
  • Skip to step "Ready to compile ScummVM"

Building the libraries yourself

Refer to the instructions for compiling the libraries yourself


Adding all libraries to Visual Studio

There are two ways of adding the libraries to Visual Studio. You can either copy all the header and library files inside the appropriate directories of Visual C++ or tell Visual C++ where to look for them.

First method: Copy the files inside VC++'s folders

The first method of adding the required libraries is to go to each individual compiled library and copy the header and library files.

You'll need the following:

Libraries

 libFLAC_static.lib - static build of libFLAC (from folder obj\release\lib where you unzipped libFLAC)
 libmad.lib - static build of libMAD (from folder msvc++\Release where you unzipped libmad)
 libmpeg2.lib - static build of libMPEG2 (from folder vc++\Release where you unzipped mpeg2dec)
 libpng.lib - static build of libpng (from folder projects\visualc71\Win32_LIB_Release where you unzipped libpng)
 ogg_static.lib - static build of libOGG (from folder win32\Static_Release where you unzipped libogg)
 sdl.lib - static build of SDL (from folder lib where you unzipped SDL)
 vorbisfile_static.lib - static build of vorbisfile (from folder win32\VorbisFile_Static_Release where you unzipped libvorbis)
 vorbis_static.lib - static build of libvorbis (from folder win32\Vorbis_Static_Release where you unzipped libvorbis)
 vorbisenc_static.lib - static build of libvorbis (from folder win32\Vorbisenc_Static_Release where you unzipped libvorbis)
 zlib.lib - static build of zlib (from folder projects\visualc6\Win32_LIB_Release where you unzipped zlib)

Copy those inside VC's lib folder (e.g. C:\Program Files\Microsoft Visual Studio 8\VC\lib)

Header files

 [TODO]

Copy those inside VC's include folder (e.g. C:\Program Files\Microsoft Visual Studio 8\VC\include)

Executable files

 nasmw.exe - from the NASM zip

Copy this as nasmw.exe AND as nasm.exe inside VC's bin folder (e.g. C:\Program Files\Microsoft Visual Studio 8\VC\bin)

Second method: Tell VC++ where to look

The second method is to tell VC++ where to look for the required libraries and header files

Go to Tools->Options->Projects and solutions->VC++ directories.

In the executable files section, make sure that the path to nasm is included and that nasmw.exe in that folder has been copied to nasm.exe. Failure to do that will give you an error in VS (a custom building step has returned an error)

In the include files section, make sure that the include folders for libogg, libvorbis, libmad, zlib, mpeg2dec and SDL are in the list. If you need FLAC, include the FLAC include folder in the list too

In the library files section, make sure that the static libraries for vorbis, vorbisfile, libogg, zlib, mpeg2dec, libmad and SDL are included. If you're building 0.8.0 final or earlier, include the release folder of zlibdll too (in the zlib source folder, contrib\vstudio\vc8\x86\zlibdllrelease). If you need FLAC, include the FLAC libraries folder too

Finally, if you need to compile ScummVM with FLAC support, go to Configuration Properties->C/C++->Preprocessor and add "USE_FLAC" in the Preprocessor Definitions field. Also, go to linker->input and add "libflac_static.lib" in the Additional Dependencies field.


Enabling the console

Since information on doing this is not that easy to find, here's how to enable the console in the resulting ScummVM executable. The default project subsystem is "Windows" instead of "Console", which means that the console will not be shown.

To show the console, right-click on the "scummvm" project and go to Properties. There, go to Configuration Properties->Linker->System and change the "Subsystem" property from "Windows (/SUBSYSTEM:WINDOWS)" to "Console (/SUBSYSTEM:CONSOLE)". Then, go to Linker->Advanced and set the entry point to be "WinMainCRTStartup" (special thanks to Jubanka/knakos for his tip on entrypoint).


Ready to compile ScummVM

If you got all the libraries compiled, you're ready to compile the latest version of ScummVM!

Open the solution file in dists\msvc9 (msvc8 for VS2005 and msvc7 for VS2003), select the "Release" configuration from the configuration manager pulldown menu and then go to Build->Build solution, or just press Control-F7 to compile it.

The ScummVM executable should be in the folder dists\msvc9\scummvm_Release as "scummvm.exe".

You'll need to copy sdl.dll from the SDL runtime archive (or the latest devel archive) in the directory where scummvm.exe is