HOWTO: Compile ScummVM with Visual Studio under Windows

General chat related to ScummVM, adventure gaming, and so on.

Moderator: ScummVM Team

Post Reply
User avatar
md5
ScummVM Developer
Posts: 2261
Joined: Thu Nov 03, 2005 9:31 pm
Location: Athens, Greece

HOWTO: Compile ScummVM with Visual Studio under Windows

Post by md5 »

HOWTO: Compile ScummVM with Visual Studio 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, so I thought it would be a good idea to write a small howto

These instructions are for VS 2005, however the steps needed are exactly the same for VS 2003 and propably VS 6.0 and earlier.

The following libraries are needed:
- SDL 1.2: http://www.libsdl.org/download-1.2.php
You need the file SDL-devel-1.2.9-VC6.zip (1.2.9 is the latest version at this time)
- NASM: http://www.kernel.org/pub/software/deve ... ies/win32/
- libogg: http://downloads.xiph.org/releases/ogg/
- libvorbis: http://downloads.xiph.org/releases/vorbis/
Note that the libraries included in the "vorbis" package won't work. You need libogg and libvorbis, not vorbis
- libmad: ftp://ftp.mars.org/pub/mpeg/
- libmpeg2: http://libmpeg2.sourceforge.net/downloads.html
Get the latest mpeg2dec release from this page, libmpeg2 is included there
- zlib: http://www.zlib.net/
You need the latest zlib compiled DLL
If you wish to compile version 0.8.0 stable or earlier, you'll also need the zlib source code plus this file:
http://www.winimage.com/zLibDll/crtdll.zip

Now, we need to compile the required libraries. Note that if you're building the libraries with VS2005, you will get a lot of deprecation warnings. These are normal and nothing to worry about, they're just Microsoft's way of saying "This is a bad code practice. Use this instead". It's not easy to turn these off without several modifications to the code, so just ignore them. Read more here:
http://msdn.microsoft.com/msdnmag/issue ... SafeCandC/
http://www.gamedev.net/community/forums ... _id=361433
http://blogs.msdn.com/oldnewthing/archi ... 48437.aspx

If you do wish to make them disappear, you need to include on top the main function of each library, before the includes, the following lines:

Code: Select all

#if (_MSC_VER >= 1400) /* VC8+ (VS2005) */
#pragma warning(disable : 4996) /* Disable all deprecation warnings */
#endif /* VC8+ (VS2005) */
Note that you'll need to build all libraries with the same configuration settings (debug or release).

NASM
====
First of all, we need nasm. So unzip the nasm archive in a directory, copy
"nasmw.exe" to "nasm.exe" (because some projects call one and others call the other) and include it in the executable path of VS. To do this, go to Tools->Options->Projects and solutions->VC++ directories. Select "Executable files" from the top right and include the directory where you unzipped nasm into.

SDL/zlib
======
SDL and zlib are already compiled, so we can skip the compilation step for those two

If you wish to compile ScummVM 0.8.0 stable and earlier, you'll also need zlib source. Go in the contrib\vstudio\vs8 directory (or vs7 if you're using VS2003), unzip crtdll.lib from the zip you downloaded earlier in the directory and compile zlibvc

libogg
=====
Compile this first, as many other libraries need it. Go to the win32 directory and build the ogg solution in there. DON'T compile the solution in the VS2003 directory, as this produces "libogg.lib" instead of "ogg.lib". A simple rename might work, but I'm not sure

libvorbis
======
Before compiling this, include the libogg include and library paths in VS. To do this, go to Tools->Options->Projects and solutions->VC++ directories and include the include directory of libogg as well as the directory with the compiled ogg library

mpeg2dec
========
After you compile this one, go to its include directory, create a folder "mpeg2dec" in there and copy all files from the include folder in this subfolder. So you should end up with 2 directories, "include" and "include\mpeg2dec" with the same files. This is needed, as ScummVM includes files from the "mpeg2dec" directory

libmad
=====
To compile this, you need to remove all the "_CRTRESTRICT" directives from the code, as VS doesn't understand this directive

FLAC
====
Not a necessary library, so you may skip this one. If you do wish to include it, go to the configuration manager and exclude "in_flac" from compilation. This is due to the fact that you don't need that library (it's for Winamp) but also it won't compile with VS2005, because of many things that VS2005 doesn't like in tagz.cpp from Winamp's SDK. You'll also need to copy ogg_static.lib from the ogg library into the obj\release\lib folder

Adding all libraries to Visual Studio
=========================
Now that we got all libraries compiled, we 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

Before compiling
============
Open the solution file in dists\vc8 (or vc7 if you're using VS2003)

Before compiling, open the file sound\softsynth\ym2612.cpp in the scummvm directory with VS and save it as unicode. To do this, go to File->Save as and in the save button, click the small arrow next to it and select "Save with encoding" and select "UTF8" from the list. You need to do the same with file kyra\script_v1.cpp, although that wasn't enough for my case. I had to remove all japanese text from script_v1.cpp in order to compile it with VS. The reason for this step is that those files contain Japanese characters, so VS refuses to compile the project if those files are not saved as unicode

After compiling, don't forget to copy "sdl.dll" in the release and debug directories where scummvm.exe is located

Ready to go!
=========
OK this should be all of it (thankfully), so you should be good to go. I haven't included instructions to include FLAC, since that's not needed to build ScummVM.

Note that whenever you get a new release from the scummvm website, you need to follow the steps in the "before compiling" section to compile scummvm

Any additions or corrections to this guide are more than welcome :)

joachimeberhard
ScummVM Team Member
Posts: 378
Joined: Sat Sep 24, 2005 12:25 pm
Location: Austria

Post by joachimeberhard »

What a great tutorial.

Just what I need.

Thanks!

Joachim

User avatar
dreammaster
ScummVM Developer
Posts: 399
Joined: Fri Nov 04, 2005 2:16 am
Location: San Jose, California, USA

Post by dreammaster »

Yes, this would certainly have been helpful to me a few months back when I needed to start compiling ScummVM myself to work on the Lure module. I'll just add that I've been using the vs7 and at the time I started compiling it, the project file tree was a little bit out of date, with some entries needing to be removed and added to get it to compile properly.

No biggy - it's entirely possible that they've fixed it since then, but I just thought I'd mention it.

Note to admins: This is the sort of good guide that could usefully be included in the website documentation area for any future users that would like to compile under VS.
Last edited by dreammaster on Sat Jan 14, 2006 9:43 pm, edited 1 time in total.

User avatar
glokidd
Posts: 364
Joined: Wed Nov 02, 2005 6:50 am
Location: british columbia, canada
Contact:

Post by glokidd »

thanks a lot, i had sorta stalled on my attempts to figure this out, due to pure noob confusion. :oops: maybe this should be stickied or added to the documentation page or someting

Thanks again man

User avatar
sev
ScummVM Lead
Posts: 2019
Joined: Wed Sep 21, 2005 1:06 pm
Contact:

Post by sev »

md5 already was provided with ScummVM Wiki account, so it will be put there and maintainded.


Eugene

Kreeblah
Posts: 1
Joined: Sun Nov 06, 2005 12:15 am

Post by Kreeblah »

A quick correction, at least for me.

I was able to compile libmad just fine from the source tree. It was mpeg2dec that was giving me issues. I had to edit config.h in the vc++ directory and change:

#define restrict __restrict

to

#define restrict

since VS2005 Express Edition (and maybe others, but this is the only version of 2005 that I've used) has issues with __restrict.

Edit: I was able to compile ScummVM using the msvc8 project in the dists directory without converting any files to UTF8.

As a side note, I went ahead and modified FLAC, libmad, mpeg2dec, libogg, and libvorbis to eliminate the deprecated API warnings (and in the case of mpeg2dec, to compile at all) and converted all the projects to VS2005 projects. You can get an archive of them here.

I know there's a cleaner way to have done the warning suppression, but I just added the #if etc. with the #pragma to each .c, .cpp, and .h file (yes, even ones that didn't need it, some blatantly so - I was only half paying attention and didn't want to go through the source code to find out which ones actually needed to have that). Still, it should be pretty straightforward. Check BuildNotes.txt for a couple oddities, but for the most part it's just "open the solution file and build", assuming you've got the appropriate libraries and includes in your paths somewhere.

I have successfully compiled and run ScummVM with these libraries, so hopefully they'll work for other people, too.

Post Reply