Jump to navigation Jump to search
no edit summary
== Compiling ScummVM with Visual Studio 2008/2010 under Windows ==
 Compiling ScummVM under Windows with Visual Studio is not an awfully hard task, . It is however there are some things that don't just work out of slightly more complicated than using MinGW. We guide you through the boxsteps to make ScummVM compile with Visual Studio on this page.
== Things needed ==
Visual Studio 2008-2019
=== Visual Studio 2010 or 2008 ===There exist several versions of Visual Studio 2010. A feature comparison can be found [ here] You can obtain the exists a free Express Community version of Visual C++ 2010 Studio [http 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:** [ Mirror 1]** [ Mirror 2] (RapidShare)* 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 "[[Compiling_ScummVM/Visual_Studio#Adding_all_libraries_to_Visual_Studio|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 "[[Compiling_ScummVM/Visual_Studio#Ready to compile ScummVM|Ready to compile ScummVM]]" === Libraries needed === * [ SDL 1.2], file (where XX is the current release number)Latest stable version at the time of writing this: [ 1.2.14] * [ NASM]Latest stable version at the time of writing this: [ 2.06rc12] * [ libogg] and [ libvorbis] for OGG support. Note that the libraries included in the "vorbis" package won't work. You need libogg and libvorbis, not vorbis.Latest stable versions at the time of writing this: [ 1.1.4] and [ 1.2.3]. * [ libmad] for MP3 support. Latest stable version at the time of writing this: [ 0.15.1b] * [ libFLAC] for FLAC support.Latest stable version at the time of writing this: [ 1.2.1] * [ libmpeg2] for MPEG-2 support. Get the latest mpeg2dec release from this page, libmpeg2 is included there. Latest stable version at the time of writing this: [ 0.5.1] * [ zlib]You need the latest zlib source code. If you wish to compile ScummVM 0.8.0 or earlier with zlib support, you'll also need [ crtdll.lib].Latest stable version at the time of writing this: [ 1.2.3] * [ libpng] (for ScummVM tools)You need the latest libpng source code.Latest stable version at the time of writing this: [ 1.2.36] == Building the libraries == Now, we need to compile the required libraries. Note that you'll need to build all libraries with the same configuration settings (debug or release). If you don't need a specific library, you can remove it from your build by going to Project->Properties, Configuration Properties->C/C++->Preprocessor and remove the "USE_XXX" directive for that library from there. For example, to remove OGG support, remove the USE_VORBIS directive. Also, make sure to disable the inclusion of default libraries in all libraries. You can do this from the project properties->Librarian->General and setting "Ignore all default libraries" to "Yes (/NODEFAULTLIB)" (special thanks to nolange for this tip). Finally, make sure that optimization is set to "Maximize speed" (or anything other than "Full optimization"), otherwise it will be impossible to build incremental debug builds later on (you'll get a warning saying "ignoring '/INCREMENTAL' due to '/LTCG' specification"). You can do this from the project properties->C/C++->Optimization, and set "Optimization" to "Maximize Speed (/O2)"  === A note about VS2008/2005 === If you're building the libraries with VS2008/2005, 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: 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:   #if (_MSC_VER >= 1400) /* VC8+ (VS2005) */ #pragma warning(disable : 4996) /* Disable all deprecation warnings */ #endif /* VC8+ (VS2005) */  === 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 === SDL is already compiled and needs no further changes, so we can skip the compilation step for it. '''Note for x64''': You will need to compile SDL for x64 on your own (as of the time of this writing), to do so you will also need to install the [ DirectX SDK found here]. You will also need to apply this patch [ from here] (patch gladly taken from the SDL mailing list). After adding a new x64 configuration option in the project files, you may also need to remove "/MACHINE:I386" as additional linker command in Project->Properties, Configuration Properties->Linker->Command Line. === zlib === You'll need the zlib source package. After unzipping it, go into the projects directory in the zlib source and open the solution under projects\visualc6. Right click on the "zlib" project, and go to its properties. Then, go to Configuration Properties->C/C++->Code Generation and change the Runtime library from "Multi-Threaded DLL (/MD)" to "Multi-Threaded (/MT)" (if you don't do this step, you'll have issues compiling ScummVM later on). Then, compile the "zlib" project using the LIB release configuration.  === libogg === Compile this first, as many other libraries need it. Go to the win32 directory and build the "libogg_static" solution of your MSVC version (which should be found in one of the sub-directories). The solution should feature working x86 (Win32) and x64 (x64) targets by default, so you can compile either of those depending on whether you decide to build an x86 or x64 ScummVM. === libvorbis === You will need to use the "vorbis_static" solution. It should feature working x86 (Win32) and x64 (x64) targets by default. '''Note''': When you do not include your ogg headers/libraries in your global MSVC path settings you will need to do the following: 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. You'll need vorbis, vorbisfile and also vorbisenc for ScummVM tools. === libmpeg2 === The VC6 solution files (inside the vc++ folder) need to be used for this library, but first they all need to be changed to DOS format, otherwise Visual Studio will complain that the project files are corrupted. Then, open file config.h inside the vc++ folder and comment out the following line, near the end of the file: #define restrict __restrictOpen the solution and compile project "libmpeg2". After you compile it, go to its include directory, create a folder "mpeg2dec" in there and copy all files from the include folder in this subfolder. You will 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 === Open and compile the "libmad" solution '''Note for x64:''' When you want to build a x64 library for libmad you will need to create your own x64 config for it. You can do so by easy conversion of the existing libmad solution files for x86. For Release mode you will also need to edit the preprocessor definitons via: Properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions: there you will need to replace "FPM_INTEL" with "FPM_64BIT". You will also need to apply the following patch to mad.h: [ mad.patch] === FLAC === Open its solution and compile the libFLAC_static project. By default, optimization for this library is set to "full" in release builds, which will prevent you from performing incremental debug builds later on, so make sure to set it to "Maximize speed" (or anything other than "Full optimization"), otherwise it will be impossible to build incremental debug builds later on. Check the introductory section for more information. Also, FLAC OGGs are not needed, so support for these can be dropped by going to the libFLAC_static project settings and removing the FLAC__HAS_OGG switch from C/C++->Preprocessor->Preprocessor Definitions. '''Note for x64''': After converting the Win32 target to x64 you will need to adapt some file settings. First of all you will need to disable all *.nasm files in the "libFLAC_static" project, this can be easily done by right clicking on them and selecting "Properties", now set "Excluded From Build" to "true". Next you will need to adapt the Preprocessor Definitions: First of all remove the following defintions: "FLAC__CPU_IA32", "FLAC__HAS_NASM" and "FLAC__USE_3DNOW", now also add "FLAC__NO_ASM". Last but not least you will need to apply the following patch file to "bitreader.c" of the "libFLAC_static" project: [ flac.patch] === libpng === Open the solution under projects\visualc71. You also need zlib to compile this library, which must be placed in a folder named "zlib" outside libpng's directory. You need to change the settings of zlib like you have done before (i.e. from "Multi-Threaded DLL (/MD)" to "Multi-Threaded (/MT)"). Check the zlib section for more information.  == Adding all libraries to Professional Visual Studio == There Studioversions 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.<br><br> === 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:<br><br>'''Libraries'''<br> '''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)<br><br>'''Header files'''<br> [TODO] Copy those inside VC's include folder (e.g. C:\Program Files\Microsoft Visual Studio 8\VC\include)<br><br>'''Executable files'''<br> '''nasmwworking fine too.exe''' - from the NASM zip
Copy We do support older versions of Visual Studio too. However, on this as nasmw.exe AND as nasmpage we focus on building ScummVM with Visual Studio.exe inside VC's bin folder (e.g. C:\Program Files\Microsoft Building ScummVM with older Visual Studio 8\VC\bin)<br><br>2008 can require additional work not described on this page.
=== Second method: Tell VC++ where to look Needed Libraries ===The '''second method''' is ScummVM relies on third-party libraries to tell VC++ where to look implement certain functionality. Some of these libraries are required, like for example SDL, others are optional, like for example libtheora. We supply a set of prebuilt libraries for Visual Studio 2015. These have been build on Windows 8.1 using the required Visual Studio 2015 Community Edition. The libraries and header filescan be found [ here].
=== Installing Libraries ===The easiest way to make Visual Studio find the supplied libraries is by using the environment variable "SCUMMVM_LIBS". We describe this method now.To make it work you have to follow these steps:* Unzip the library zip to a directory of your choice. For example, you can unzip them into "C:\Users\YourUsername\Documents\scummvm_libs_2015".* Go to ToolsControl Panel ->Options->Projects Environment Variables and set up a new variable "SCUMMVM_LIBS" with a value of the path you extracted the zip in. It is important that you do point the variable to the folder containing the "bin", "include", and solutions->VC++ "lib" directories.
In === Manually Building Libraries ===If you want to build libraries for use with Visual Studio yourself, please refer to the executable files section, make sure that [[Compiling_ScummVM/Visual_Studio/Compiling_Libraries|instructions for compiling the path to nasm is included and that nasmwlibraries yourself]].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 == Preparing 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 Project Files ==
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 === Building create_project ===
Finally, if you need to compile ScummVM with FLAC support, go uses a configure/Make based build system. We have a tool to Configuration Properties->C/C++->Preprocessor and add "USE_FLAC" in the Preprocessor Definitions fieldgenerate Visual Studio project files from this build system. Also, go The first steep you need to linker->input and add take is building this tool called "libflac_static.libcreate_project" in the Additional Dependencies field.
First, open the solution file "devtools\create_project\msvc\create_project.sln". Then simply build the solution. The project file should automatically assure that the resulting "create_project.exe" is copied to "dists\msvc". If not, you will have to copy it yourself.
== Enabling = Generating the console Project Files ===
Since information on doing this is not that easy to find, here's how to enable Simply run the console in the resulting ScummVM executablebatch script "dists/msvc/create_msvc.The default project subsystem is bat"Windows" instead of "Console", which means that the console . It will not be shownguide you through configuring ScummVM.
To show the console, right'''IMPORTANT''': You will have to re-click on generate the "scummvm" project and go files whenever new source files have been added to Properties. There, go to Configuration Properties->Linker->System and change or removed from the "Subsystem" property from "Windows (configure/SUBSYSTEM:WINDOWS)" Make based build system. When you add new files to "''ScummVM, you will 'Console (/SUBSYSTEM:CONSOLE)'have''". Then, go to Linker->Advanced and set add them to the entry point to be respective "'''WinMainCRTStartup'''" (special thanks file to [[User:Jubanka|Jubankaassure ScummVM still builds fine with the configure/knakos]] for his tip on entrypoint)Make based build system.
== Compiling ScummVM ==
== Ready If you followed all the steps, you are now ready to compile ScummVM ==with Visual Studio. Congratulations!
If you got all Simply open the libraries compiled, generated solution file in "dists\msvc\scummvm.sln". Now you're ready can ask it to compile build the latest version of desired configuration. By default it will build a debug configuration which is ideal to hack on ScummVM!.
Open '''IMPORTANT''': You'll need to copy the matching SDL.dll file to a location Windows picks up to run the solution resulting binary. The easiest way to do this is to place the SDL.dll file in dists\msvc9 (msvc8 for VS2005 and msvc7 for VS2003)the directory where scummvm.exe is. There are multiple SDL.dll files to choose from, select depending on your build configuration. Simply pick the "Release" configuration right one from the prebuilt libraries. For example, if you build a Win32 Debug configuration manager pulldown menu and then go to Build->Build solution, or just press Control-F7 you will need to compile ituse "libs/x86/Debug/SDL.dll".
The ScummVM executable should be in the folder dists\msvc9\scummvm_Release as "scummvm.exe".== Compiling without Console/Status Window ==
You'll If you want to run ScummVM without the console Window being present by default, there are two things you need to copy do:* In the Project Options for the scummvm project, go to the Linker | System | SubSystem line, and change the /SUBSYSTEM:CONSOLE to /SUBSYSTEM:WINDOWS* In the file backends/platform/sdl/win32/win32.dll cpp, change the parameter from true to false in the SDL runtime archive first line of OSystem_Win32::initBackend: ConfMan.registerDefault(or the latest devel archive"console", false) in the directory where scummvm.exe is;

Navigation menu