Jump to navigation Jump to search

Compiling ScummVM/Visual Studio/Compiling Libraries

1,604 bytes removed, 17:08, 25 October 2018
Text replacement - "</source>" to "</syntaxhighlight>"
== Instructions for compiling the needed libraries for Visual Studio yourself ==
=== Libraries needed ===Building libraries for use with Visual Studio is a complicated process. Many libraries only feature out-dated project files or have incompatible configurations for their project files. On this page we give a general introduction of the settings we used for building the libraries with Visual Studio 2015 Community Edition. Afterwards, we give a more detailed view on the process of building each invidiual library.
We used the following settings when compiling the libraries:* [httpRun-Time Library:// use the "Multi-Threaded DLL" run-1time library.2.php SDL 1.2], file SDLFor Debug configurations we use the "Multi-devel-1Threaded Debug DLL" (option "/MDd").2.XXFor Release configurations we use the " Threaded DLL" (where XX is the current release numberoption "/MD").Latest stable version at the * Link-time of writing thisCode Generation: [httpWe disable LTCG for all configurations (option "/LTCG://wwwOFF")* Whole Program Optimization: We disable WPO for all configurations (option "/SDLGL-devel-1") 1.2Please assure that any libraries you build use exactly the same configuration settings.14]
* [ NASM]Latest stable version at the time of writing this: [ 2.09.10]== Special Instructions for Libraries ==
* [ libogg] and [ libvorbis] for OGG support. Note that the Here, we will take a look at libraries included in the "vorbis" package won't work. You which need libogg and libvorbis, not vorbis.Latest stable versions at the time of writing this: [ 1.3.0] and [ 1.3.2]special handling when built with Visual Studio.
* [ftp://ftp=== SDL libmad] for MP3 support. Latest stable version at the time of writing this: [ 0.15.1b]2 ===
* [http://sourceforgeWe used the following patch when compiling SDL libFLAC] 2, which is required for FLAC x64 support.Latest stable version at The patch was gladly taken from the time of writing this: [ 1SDL mailing list.2.1]
* [http:<syntaxhighlight lang="diff">--- src/video/libmpeg2.sourceforge.netwindx5/downloadsSDL_dx5video.html libmpeg2] for MPEG-2 support - '''no longer needed'''.Get the latest mpeg2dec release from this page, libmpeg2 is included there. Latest stable version at the time of writing thisc Tue Oct 13 00: [http07:16 2009+++ src/video/libmpeg2.sourceforge.netwindx5/files/libmpeg2-0SDL_dx5video.5.1.tar.gz 0.5.1]c Tue Nov 03 21:14:38 2009@@ -332,7 +332,7 @@* [ zlib]You need the latest zlib source code. If you wish to compile ScummVM 0.8.0 or earlier with zlib support { &GUID_Key, 255, 0x8000FF0C, 0x00000000 }, you'll also need [ crtdll.lib].Latest stable version at the time of writing this: [ 1.2.5] }; * [ libpng] -const DIDATAFORMAT c_dfDIKeyboard = { sizeof(for ScummVM toolsDIDATAFORMAT), in particular convert_dxasizeof(DIOBJECTDATAFORMAT), 0x00000002, 256, 256, KBD_fmt };You need the latest libpng source code.Latest Windows stable version at the time of writing this: +const DIDATAFORMAT c_dfDIKeyboard = { sizeof(DIDATAFORMAT), sizeof(DIOBJECTDATAFORMAT), DIDF_RELAXIS, 256, sizeof(KBD_fmt)/sizeof(KBD_fmt[ 1.5.50]), KBD_fmt }; == Building the libraries == /* Mouse */@@ -347,7 +347,7 @@Now { NULL, 15, 0x80FFFF0C, 0x00000000 }, we need to compile the required libraries. }; Note that you'll need to build all libraries with the same configuration settings -const DIDATAFORMAT c_dfDIMouse = { sizeof(DIDATAFORMAT), sizeof(debug or releaseDIOBJECTDATAFORMAT). If you don't need a specific library, you can remove it from your build by going to Project->Properties0x00000002, Configuration Properties->C/C++->Preprocessor and remove the "USE_XXX" directive for that library from there. For example16, to remove OGG support7, remove the USE_VORBIS directive.PTR_fmt }; 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 +const DIDATAFORMAT c_dfDIMouse = { sizeof(/NODEFAULTLIBDIDATAFORMAT)" , sizeof(special thanks to nolange for this tipDIOBJECTDATAFORMAT). Finally, make sure that optimization is set to "Maximize speed" DIDF_RELAXIS, sizeof(or anything other than "Full optimization"DIMOUSESTATE), otherwise it will be impossible to build incremental debug builds later on sizeof(you'll get a warning saying "ignoring '/INCREMENTAL' due to '/LTCG' specification"PTR_fmt). You can do this from the project properties->C/C++->Optimization, and set "Optimization" to "Maximize Speed sizeof(/O2PTR_fmt[0])", PTR_fmt }; static DIOBJECTDATAFORMAT PTR2_fmt[] === A note about VS2008/2005 ==={ If you're building the libraries with VS2008/2005 { &GUID_XAxis, 0, you will get a lot of deprecation warnings. These are normal and nothing to worry about0x00FFFF03, 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 code0x00000000 }, so just ignore them. @@ -363,7 +363,7 @@Read more here: { NULL, 19, 0x80FFFF0C, 0x00000000 } }; -const DIDATAFORMAT c_dfDIMouse2 = { sizeof(DIDATAFORMAT), sizeof(DIOBJECTDATAFORMAT), 0x00000002, 20, 11, PTR2_fmt }; DIDATAFORMAT c_dfDIMouse2 =361433 If you do wish to make them disappear{ sizeof(DIDATAFORMAT), you need to include on top the main function of each librarysizeof(DIOBJECTDATAFORMAT), before the includesDIDF_RELAXIS, the following lines:   #if sizeof(_MSC_VER >= 1400DIMOUSESTATE) /* VC8+ , sizeof(VS2005PTR2_fmt) */ #pragma warningsizeof(disable : 4996PTR2_fmt[0]) , PTR2_fmt }; /* Disable all deprecation warnings Joystick */ #endif /* VC8@@ -415,7 + (VS2005) */415,7 @@ { NULL, 79, 0x80FFFF0C, 0x00000000 }, }; -const DIDATAFORMAT c_dfDIJoystick === NASM === First of all{ sizeof(DIDATAFORMAT), sizeof(DIOBJECTDATAFORMAT), 0x00000001, 80, we need nasm. So unzip the nasm archive in a directory44, copy JOY_fmt };"nasmw.exe" to "nasm.exe" +const DIDATAFORMAT c_dfDIJoystick = { sizeof(DIDATAFORMAT), sizeof(because some projects call one and others call the otherDIOBJECTDATAFORMAT) 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 changesDIDF_ABSAXIS, so we can skip the compilation step for it. '''Note for x64''': You will need to compile SDL for x64 on your own sizeof(as of the time of this writingDIJOYSTATE), to do so you will also need to install the sizeof(JOY_fmt)/sizeof(JOY_fmt[ DirectX SDK found here0]. You will also need to apply this patch [http:), JOY_fmt }; /* Initialization/robertmegone.comQuery functions */scummvm</build/sdl.patch from here] (patch gladly taken from the SDL mailing list).syntaxhighlight>
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 We used a custom project file when building zlib source package. After unzipping it, go into the projects directory in to get the old standard library name "zlib source and open the solution under projects\vstudio. Right click on the lib"zlib" project, and go to its properties. Then, go to Configuration Properties->C/C++->Code Generation and change It can be found inside a zip file in the Runtime library from "Multi-Threaded DLL (patches/MD)" to "Multidirectory of our pre-Threaded (/MT)" (if you don't do this step, you'll have issues compiling ScummVM later on)built library package. Then, compile the "The project file was created for zlib" project using the LIB release configuration1.2.8.
=== libogg ===
Compile this first, as many other libraries need it. Go to the win32 directory and build We use 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 ScummVMcreate a library for static linking.
=== 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 You need to do assure that the following: include the libogg include headers (and library paths libraries in VS. To do this, go to Tools->Options->Projects and solutions->VC++ directories and include the include directory case you build a dynamically linked libvorbis) of libogg as well as are in the directory with the compiled ogg library. You'll need vorbis, vorbisfile and also vorbisenc for ScummVM toolspaths MSVC searches.
'''Note''': The static solution can be bugged and produce a library named "libvorbisfile.lib" instead of "libvorbisfile_static.lib". You will need to fix the target name in the project settings. '''Note''': You'll need vorbis, vorbisfile and also vorbisenc for ScummVM tools. === libmpeg2 libtheora === You will need to use the "libtheora_static" solution.
'''Note''': The VC6 static solution files (inside the vc++ folder) need to can be used for this bugged and produce a library, but first they all need to be changed to DOS format, otherwise Visual Studio will complain that the project files are corruptednamed "libtheora. Then, open file config.h inside the vc++ folder and comment out the following line, near the end lib" instead of the file: #define restrict __restrictOpen the solution and compile project "libmpeg2libtheora_static.lib". After you compile it, go You will need to its include directory, create a folder "mpeg2dec" in there and copy all files from fix the include folder target name in this subfolder. You will end up with 2 directories, "include" and "include\mpeg2dec" with the same filesproject settings. This is needed, as ScummVM includes files from the "mpeg2dec" directory
=== libmad ===
Open and compile You can use 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:
<source syntaxhighlight lang="diff">
--- mad.h Tue Nov 03 18:29:06 2009
+++ mad.h Tue Nov 03 18:29:14 2009
# define FPM_INTEL
=== FLAC ===
Open its the FLAC solution and compile the build "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 and "Full optimizationwin_utf8_io_static"), 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]=== libfaad ===
We used the following patch when compiling libfaad to adjust for changes in the MSVC runtime: <syntaxhighlight lang="diff">diff -ru '--exclude=*vcx*' '--exclude= libpng *sln*' sources.orig/faad2-2.7/libfaad/common.h sources/faad2-2.7/libfaad/common.h--- sources.orig/faad2-2.7/libfaad/common.h 2009-02-05 01:51:03.000000000 +0100+++ sources/faad2-2.7/libfaad/common.h 2016-03-09 20:27:08.851178000 +0100@@ -315,7 +315,7 @@ #if defined(_WIN32) && !defined(__MINGW32__) #define HAS_LRINTF- static INLINE int lrintf(float f)+ /*static INLINE int lrintf(float f) { int i; __asm@@ -324,7 +324,7 @@ fistp i } return i;- }+ }*/ #elif (defined(__i386__) && defined(__GNUC__) && \ !defined(__CYGWIN__) && !defined(__MINGW32__)) #ifndef HAVE_LRINTFdiff -ru '--exclude=*vcx*' '--exclude=*sln*' sources.orig/faad2-2.7/libfaad/mp4.c sources/faad2-2.7/libfaad/mp4.c--- sources.orig/faad2-2.7/libfaad/mp4.c 2009-02-06 04:39:58.000000000 +0100+++ sources/faad2-2.7/libfaad/mp4.c 2016-03-09 20:27:09.200404900 +0100@@ -32,6 +32,7 @@ #include "structs.h" #include <stdlib.h>+#include <string.h> #include "bits.h" #include "mp4.h"diff -ru '--exclude=*vcx*' '--exclude=*sln*' sources.orig/faad2-2.7/libfaad/ps_dec.c sources/faad2-2.7/libfaad/ps_dec.c--- sources.orig/faad2-2.7/libfaad/ps_dec.c 2009-01-26 23:32:31.000000000 +0100+++ sources/faad2-2.7/libfaad/ps_dec.c 2016-03-09 20:27:09.233469100 +0100@@ -33,6 +33,7 @@ #ifdef PS_DEC #include <stdlib.h>+#include <string.h> #include "ps_dec.h" #include "ps_tables.h" diff -ru '--exclude=*vcx*' '--exclude=*sln*' sources.orig/faad2-2.7/libfaad/sbr_hfadj.c sources/faad2-2.7/libfaad/sbr_hfadj.c--- sources.orig/faad2-2.7/libfaad/sbr_hfadj.c 2008-09-20 00:50:20.000000000 +0200+++ sources/faad2-2.7/libfaad/sbr_hfadj.c 2016-03-09 20:27:09.400963200 +0100@@ -40,6 +40,8 @@ #include "sbr_noise.h" +#include <string.h>+ /* static function declarations */ static uint8_t estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj,diff -ru '--exclude=*vcx*' '--exclude=*sln*' sources.orig/faad2-2.7/libfaad/sbr_syntax.c sources/faad2-2.7/libfaad/sbr_syntax.c--- sources.orig/faad2-2.7/libfaad/sbr_syntax.c 2009-01-26 23:32:31.000000000 +0100+++ sources/faad2-2.7/libfaad/sbr_syntax.c 2016-03-09 20:27:09.458518400 +0100@@ -48,6 +48,8 @@ #endif #include "analysis.h" +#include <string.h>+ /* static function declarations */ /* static function declarations */ static void sbr_header(bitfile *ld, sbr_info *sbr); </syntaxhighlight> '''Note for x64:''' When you want to build a x64 library for libfaad you will need to create your own x64 config for it. You can do so by easy conversion of the existing libfaad solution files for x86. === libmpeg2 ===
Open the We used a custom solution under projects\vstudioto build libmpeg2. You also need zlib to compile this library, which must It can be placed found inside a zip file in a folder named the "zlibpatches/" outside libpng's directory. You need to change the settings of zlib like you have done before (iour pre-built library package.eThe project file was created for libmpeg 0. from "Multi-Threaded DLL (/MD)" to "Multi-Threaded (/MT)")5. Check the zlib section for more information1.


Navigation menu