Jump to navigation Jump to search
Update library instructions.
== 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 ===
* [ libFLAC] for FLAC support.Latest stable version at We used the time of writing this: [ following patch when compiling SDL 1.2.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.5] * [ libpng] for PNG support.You need the latest libpng source code.Latest Windows stable version at the time of writing this: [ 1.5.5] * [ libfaad] for AAC support.You need the latest libfaad source code. * [ libmpeg2] for MPEG-2 support.You need the latest libmpeg2 source code from the downloads section. == Building the libraries == Now, we need to compile the which is 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 x64 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=== If you're building the libraries with VS2008, 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 the following The patch (was gladly taken from the SDL mailing list):.
<source lang="diff">
=== 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 You need to assure that the headers/(and libraries in your global MSVC path settings case you will need to do build a dynamically linked libvorbis) of libogg are in the followingpaths MSVC searches. '''Note''': include the libogg include The static solution can be bugged and produce a library paths in VSnamed "libvorbisfile.lib" instead of "libvorbisfile_static.lib". To do this, go You will need to Tools->Options->Projects and solutions->VC++ directories and include fix the include directory of libogg as well as target name in the directory with the compiled ogg libraryproject file settings.  '''Note''': You'll need vorbis, vorbisfile and also vorbisenc for ScummVM tools.
=== 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".
=== FLAC ===
Open its the FLAC solution and compile the build "libFLAC_static project. By default, optimization for this library is set to "fulland " in release builds, which will prevent you from performing incremental debug builds later on, so make sure to set it to win_utf8_io_static"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=== libfaad ===
'''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 We used the following patch file when compiling libfaad to "bitreader.c" of adjust for changes in the "libFLAC_static" projectMSVC runtime:
<source lang="diff">
diff -ru '-- srcexclude=*vcx*' '--exclude=*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/libFLAClibfaad/bitreadercommon.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 Tue Sep 11 05--- sources.orig/faad2-2.7/libfaad/mp4.c 2009-02-06 04:4839:56 200758.000000000 +0100+++ srcsources/faad2-2.7/libFLAClibfaad/bitreadermp4.c Tue Nov 2016-03 19-09 20:1927:37 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@@ -14933,13 6 +14933,23 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 @@ FLAC__CPUInfo cpu_info; };#include "sbr_noise.h"
-#ifdef _MSC_VER+#if defined (_MSC_VER) /* OPT: an MSVC built-in would be better */ static _inline FLAC__uint32 local_swap32_(FLAC__uint32 x) { x = ((x<include <8)&0xFF00FF00) | ((x>string.h>8)&0x00FF00FF); return (x>>16) | (x<<16); }
+#ifdef _WIN64 /* static function declarations */+ static void local_swap32_block_uint8_t estimate_current_envelope(FLAC__uint32 sbr_info *startsbr, sbr_hfadj_info *adj, FLAC__uint32 len)+{+ while (lendiff -ru '--) {+ exclude=*vcx*start ' '--exclude= local_swap32_(*start);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++start;+ }+}sources/faad2-2.7/libfaad/sbr_syntax.c 2016-03-09 20:27:09.458518400 +#else static void local_swap32_block_(FLAC__uint32 *start, FLAC__uint32 len) { __asm {0100@@ -17348,6 +18348,7 8 @@ done1: } }+#endif
#include "analysis.h"
+#include <string.h>+ /* static function declarations */ /* static function declarations */ static FLaC__INLINE void crc16_update_word_sbr_header(FLAC__BitReader bitfile *brld, brword wordsbr_info *sbr); 
=== libpng ===
Open the solution under projects\vstudio. 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.
=== libfaad ===
Open and compile the "libfaad" solution. You need to change the settings of libfaad like you have done before (i.e. from "Multi-Threaded DLL (/MD)" to "Multi-Threaded (/MT)"). Check the zlib section for more information.
'''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.
You will also need to apply the following patch to common.h, taken from [ mixxx's wiki]:
<source lang="diff">
--- common.h Fri Jan 02 14:19:06 2015
+++ common.h Fri Jan 02 14:19:06 2015
@@ -313,7 +313,9 @@ char *strchr(), *strrchr();
- #if defined(_WIN32) && !defined(__MINGW32__)
+ #if defined(_WIN64) && !defined(__MINGW64__)
+ // No LRINTF until someone writes an .asm file
+ #elif defined(_WIN32) && !defined(__MINGW32__)
#define HAS_LRINTF
static INLINE int lrintf(float f)
=== libmpeg2 ===
The VC6 We used a custom 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 corruptedbuild libmpeg2.For libmpeg2, ALL the MMX optimizations have to It can be disabled, as libmpeg2 is using AT&T ASM syntax (GCC style), whereas MSVC uses the Intel syntax. In order to create the project files, do the following:* Copy inttypes.h and config.h from the vc++ directory into the libmpeg2 directory* Copy attributes.h and mpeg2.h from the include directory into the libmpeg2 directory* Make sure that your project includes these files, and remove found inside a zip file in the included object (.obj) files:** alloc.c** config.h** cpu_accel.c** cpu_state.c** decode.c** header.c** idct.c** inttypes.h** motion_comp.c** mpeg2.h** mpeg2_internal.h** slice.c* Find all occurences of:<source lang="C">* #include <inttypes.h><patches/source>and change them to:<source lang="C">* #include "inttypes.h"</source>* Open config.h and comment out these lines:<source lang="C">#define ACCEL_DETECT</source><source lang="C">#define ARCH_X86</source><source lang="C">#define restrict __restrict</source>* Change configuration to "Release"* Right click projectdirectory of our pre->Properties, and make sure that the following are set correctly:** Configuration Properties->General, "Configuration type" should be "Static built library(package.lib)"** Configuration Properties->C/C++->Code Generation, "Runtime Library" should be "Multi-threaded (/MT)" ScummVM will look into the mpeg2dec directory The project file was created for mpeg2libmpeg 0.h, so copy that include into a subfolder with that name in the directory where the rest of the ScummVM library include files are5.1.


Navigation menu