Difference between revisions of "Compiling ScummVM/MinGW-w64"

From ScummVM :: Wiki
Jump to navigation Jump to search
m (Text replacement - "<source lang=" to "<syntaxhighlight lang=")
(18 intermediate revisions by 2 users not shown)
Line 12: Line 12:
Our officially supported MinGW build instructions are at [[Compiling_ScummVM/MinGW]].
Our officially supported MinGW build instructions are at [[Compiling_ScummVM/MinGW]].
|}
|}
{| border="0" cellpadding="1" cellspacing="2" style="margin-left:5em; background:#FF9999; width:80%"
|- align="center"
| '''NOTE'''
|- style="margin-left:1em; background:#ffffff;"
|- style="background:#ffffff"
| Please note that current versions of MSYS2/Mingw64 cannot be installed on Windows XP anymore. '''However, builds produced with the MSYS2/Mingw64 toolchain will still work on Windows XP.'''
|}




Line 20: Line 30:
You can find MSYS2 and installation instructions on the [[https://msys2.github.io/ MSYS2 webpage]].
You can find MSYS2 and installation instructions on the [[https://msys2.github.io/ MSYS2 webpage]].


==== Download and install the mingw-w64 compilation toolchain====
==== Download and install the necessary packages ====
The MinGW packages are named mingw-<env>-<package>, where <env> is either x86_64 or i686, depending on your architecture (64-bit and 32-bit, respectively).
The MinGW packages are named mingw-<env>-<package>, where <env> is either x86_64 or i686, depending on your architecture (64-bit and 32-bit, respectively).


To create an i686 build environment, we need to first update the already installed packages. To do that, type the following in the MSYS2 terminal:
To create an i686 or x86_64 build environment, we need to first update the already installed packages and the MSYS2 environment itself.
<source lang="bash">
To do that, type the following in the MSYS2 terminal:
pacman -Syu
<syntaxhighlight lang="bash">
</source>
pacman --noconfirm -Sy
pacman --needed --noconfirm -S bash pacman pacman-mirrors msys2-runtime
</syntaxhighlight>


Now, we need to create the default location for the additional packages:
For i686 (32-bit), type the following in the MSYS2 terminal to automatically install all packages/libraries needed to compile ScummVM:
<source lang="bash">
<syntaxhighlight lang="bash">
mkdir /mingw32
pacman -S --needed --noconfirm base-devel git mingw-w64-i686-{curl,faad2,freetype,flac,fluidsynth,libjpeg-turbo,libogg,libvorbis,libmad,libmpeg2-git,libtheora,libpng,nasm,readline,SDL2,SDL2_net,toolchain,winsparkle,zlib}
</source>
</syntaxhighlight>


Then, type the following in the MSYS2 terminal to install all the needed additional packages (more info on each package can be found in the next section):
For x86_64 (64-bit), type the following in the MSYS2 terminal to automatically install all packages/libraries needed to compile ScummVM:
<source lang="bash">
<syntaxhighlight lang="bash">
pacman -Sy base-devel git mingw-w64-i686-toolchain make mingw-w64-i686-SDL2 mingw-w64-i686-SDL2_net mingw-w64-i686-nasm mingw-w64-i686-flac mingw-w64-i686-libjpeg-turbo mingw-w64-i686-libogg mingw-w64-i686-libvorbis mingw-w64-i686-libmad mingw-w64-i686-libmpeg2 mingw-w64-i686-zlib mingw-w64-i686-libtheora mingw-w64-i686-faad2 mingw-w64-i686-libpng mingw-w64-i686-freetype mingw-w64-i686-fluidsynth mingw-w64-i686-curl mingw-w64-i686-SDL2_net mingw-w64-i686-winsparkle mingw-w64-i686-readline
pacman -S --needed --noconfirm base-devel git mingw-w64-x86_64-{curl,faad2,freetype,flac,fluidsynth,libjpeg-turbo,libogg,libvorbis,libmad,libmpeg2-git,libtheora,libpng,nasm,readline,SDL2,SDL2_net,toolchain,winsparkle,zlib}
</source>
</syntaxhighlight>
 
If you want to have the ability to compile ScummVM as a 64 bit binary with all features enabled, install the necessary packages using this command:
<source lang="bash">
pacman -S --needed git mingw-w64-x86_64-{curl,faad2,freetype,flac,fluidsynth,libjpeg-turbo,libogg,libvorbis,libmad,
libmpeg2-svn,libtheora,libpng,nasm,readline,SDL2,SDL2_net,toolchain,winsparkle,zlib}
</source>


These commands will fetch and install the packages needed for compiling, including (but not limited to) GCC 6.x, GDB, and libwinpthread-git.
These commands will fetch and install the packages needed for compiling, including (but not limited to) GCC 6.x, GDB, and libwinpthread-git.


=== Install the needed libraries ===
=== Install the needed libraries ===
''You only have to install the libraries manually if you prefer not to use the automated way in the section above. For most users, installing all packages automatically will just work fine.''
In order to compile properly, ScummVM needs you to have certain libraries installed. The command in the above section installs all of the needed packages automatically. All the libraries in the list can be installed with similar commands:
In order to compile properly, ScummVM needs you to have certain libraries installed. The command in the above section installs all of the needed packages automatically. All the libraries in the list can be installed with similar commands:
<source lang="bash">
<syntaxhighlight lang="bash">
pacman -S mingw-w64-<env>-<library>
pacman -S mingw-w64-<env>-<library>
</source>
</syntaxhighlight>
where <env> is the environment as previously stated, and <library> is the name of the library, as stated in the list (e.g. pacman -S mingw-w64-x86_64-SDL):
where <env> is the environment as previously stated, and <library> is the name of the library, as stated in the list (e.g. pacman -S mingw-w64-x86_64-SDL):


Line 59: Line 69:
* '''libogg''' and '''libvorbis'''. Optional, for OGG support.
* '''libogg''' and '''libvorbis'''. Optional, for OGG support.
* '''libmad'''. Optional, for MP3 support.
* '''libmad'''. Optional, for MP3 support.
* '''libmpeg2'''. Optional, for MPEG2 cutscene support.
* '''libmpeg2-svn'''. Optional, for MPEG2 cutscene support.
* '''zlib'''. Optional, for compressed saved games.
* '''zlib'''. Optional, for compressed saved games.
* '''libtheora'''. Optional, for Broken Sword 2.5.
* '''libtheora'''. Optional, for Broken Sword 2.5.
Line 73: Line 83:
Finally, we are ready to compile the project!
Finally, we are ready to compile the project!
To do that, just open a '''MinGW-w64''' shell (''not'' the MSYS2 shell), [http://gvsigce.sourceforge.net/wiki/index.php/Getting_started_with_MSYS#Navigating_the_file_system navigate] to the source folder where you have cloned scummvm.git, and type the following commands:
To do that, just open a '''MinGW-w64''' shell (''not'' the MSYS2 shell), [http://gvsigce.sourceforge.net/wiki/index.php/Getting_started_with_MSYS#Navigating_the_file_system navigate] to the source folder where you have cloned scummvm.git, and type the following commands:
<source lang="bash">
<syntaxhighlight lang="bash">
$> ./configure # Executes a bash script that helps you configure.
$> ./configure # Executes a bash script that helps you configure.
$> make # Executes the make program, which triggers the compilation.
$> make # Executes the make program, which triggers the compilation.
</source>
</syntaxhighlight>


If everything went well, you should have a big executable in the compilation folder, named scummvm.exe. The size of the executable comes from the debug symbols embedded in the file, so you can run the following command to shrink it:
If everything went well, you should have a big executable in the compilation folder, named scummvm.exe. The size of the executable comes from the debug symbols embedded in the file, so you can run the following command to shrink it:
<source lang="bash">
<syntaxhighlight lang="bash">
$> strip scummvm.exe
$> strip scummvm.exe
</source>
</syntaxhighlight>


== Ready to go! ==
== Ready to go! ==

Revision as of 15:13, 25 October 2018

NOTE
This guide covers only the compilation under MinGW-w64 and MSYS2 (which is very different from MinGW and MSYS), and makes heavy use of the pacman package manager, which may not be available under other MinGW setups.

We do not (officially) support building in this way and we don't recommend using this method if you want to distribute your ScummVM builds.

However, we offer preliminary support for the MSYS2/MinGW-w64 toolchain. Feel free to contact me (rootfather) either via eMail or IRC if you have questions regarding MSYS2/MinGW-w64.

Our officially supported MinGW build instructions are at Compiling_ScummVM/MinGW.


NOTE
Please note that current versions of MSYS2/Mingw64 cannot be installed on Windows XP anymore. However, builds produced with the MSYS2/Mingw64 toolchain will still work on Windows XP.


Things needed

Setup MinGW-w64 and MSYS2

You can find MSYS2 and installation instructions on the [MSYS2 webpage].

Download and install the necessary packages

The MinGW packages are named mingw-<env>-<package>, where <env> is either x86_64 or i686, depending on your architecture (64-bit and 32-bit, respectively).

To create an i686 or x86_64 build environment, we need to first update the already installed packages and the MSYS2 environment itself. To do that, type the following in the MSYS2 terminal:

pacman --noconfirm -Sy
pacman --needed --noconfirm -S bash pacman pacman-mirrors msys2-runtime

For i686 (32-bit), type the following in the MSYS2 terminal to automatically install all packages/libraries needed to compile ScummVM:

pacman -S --needed --noconfirm base-devel git mingw-w64-i686-{curl,faad2,freetype,flac,fluidsynth,libjpeg-turbo,libogg,libvorbis,libmad,libmpeg2-git,libtheora,libpng,nasm,readline,SDL2,SDL2_net,toolchain,winsparkle,zlib}

For x86_64 (64-bit), type the following in the MSYS2 terminal to automatically install all packages/libraries needed to compile ScummVM:

pacman -S --needed --noconfirm base-devel git mingw-w64-x86_64-{curl,faad2,freetype,flac,fluidsynth,libjpeg-turbo,libogg,libvorbis,libmad,libmpeg2-git,libtheora,libpng,nasm,readline,SDL2,SDL2_net,toolchain,winsparkle,zlib}

These commands will fetch and install the packages needed for compiling, including (but not limited to) GCC 6.x, GDB, and libwinpthread-git.

Install the needed libraries

You only have to install the libraries manually if you prefer not to use the automated way in the section above. For most users, installing all packages automatically will just work fine.


In order to compile properly, ScummVM needs you to have certain libraries installed. The command in the above section installs all of the needed packages automatically. All the libraries in the list can be installed with similar commands:

pacman -S mingw-w64-<env>-<library>

where <env> is the environment as previously stated, and <library> is the name of the library, as stated in the list (e.g. pacman -S mingw-w64-x86_64-SDL):

  • SDL2. Mandatory. We recently switched to SDL2. SDL 1 is still available as fallback option.
  • nasm. Optional, for faster compile of scalers.
  • flac. Optional, for FLAC support.
  • libjpeg-turbo. Optional, for JPEG support. Required for Groovie 2, Starship Titanic and Wintermute.
  • libogg and libvorbis. Optional, for OGG support.
  • libmad. Optional, for MP3 support.
  • libmpeg2-svn. Optional, for MPEG2 cutscene support.
  • zlib. Optional, for compressed saved games.
  • libtheora. Optional, for Broken Sword 2.5.
  • faad2. Optional, for AAC support.
  • libpng. Optional, for PNG support.
  • freetype. Optional, for TTF support.
  • fluidsynth. Optional, for soundfont MIDI support.
  • curl and SDL2_net. Optional, for cloud integration support.
  • winsparkle. Optional, for application updates via the WinSparkle framework.

Let's get compiling!

Finally, we are ready to compile the project! To do that, just open a MinGW-w64 shell (not the MSYS2 shell), navigate to the source folder where you have cloned scummvm.git, and type the following commands:

	$> ./configure # Executes a bash script that helps you configure.
	$> make # Executes the make program, which triggers the compilation.

If everything went well, you should have a big executable in the compilation folder, named scummvm.exe. The size of the executable comes from the debug symbols embedded in the file, so you can run the following command to shrink it:

	$> strip scummvm.exe

Ready to go!

OK this should be all of it (hopefully), so you should be good to go.

Common Issues

  • If the executable compiles correctly, but you get a "somelibrary.dll missing" error when executing it, you just need to add the following path to your PATH variable: <installdir>/msys<env>/mingw64/bin/
  • If the configure script gives an error about using msys mode, please make sure you are running the mingw-w64 win32 shell or the mingw-w64 win64 shell, and not the msys2 shell from the MSYS2 package, when building ScummVM.

DLLs required for running ScummVM on a "non-MSYS2" machine

If you want to run the ScummVM binary you just compiled on an (other) Windows machine that doesn't have mingw-w64/MSYS2 installed, you need to copy a few .dll files from the folder /your-msys2-folder/mingw64/bin (for x64 builds) or ../mingw32/bin (for x86) to the same folder as your scummvm.exe.

The following list assumes that you are building ScummVM with default settings and all engines enabled, so chances that this list will suit your needs are pretty high.

  • libbz2-1.dll
  • libfaad-2.dll
  • libFLAC-8.dll
  • libfluidsynth-1.dll
  • libfreetype-6.dll
  • libgcc_s_seh-1.dll
  • libglib-2.0-0.dll
  • libgraphite2.dll
  • libharfbuzz-0.dll
  • libiconv-2.dll
  • libintl-8.dll
  • libjpeg-8.dll
  • libmad-0.dll
  • libmpeg2-0.dll
  • libogg-0.dll
  • libpcre-1.dll
  • libpng16-16.dll
  • libportaudio-2.dll
  • libsndfile-1.dll
  • libspeex-1.dll
  • libstdc++-6.dll
  • libtheoradec-1.dll
  • libvorbis-0.dll
  • libvorbisenc-2.dll
  • libvorbisfile-3.dll
  • libwinpthread-1.dll
  • SDL.dll/SDL2.dll (depends on the SDL version you used for compilation. Default is SDL2.dll)
  • zlib1.dll

Please note that compiling ScummVM with other options (e.g. "--enable-text-console") may require various other .dll files that are currently not in this list. This list will be constantly updated in the future.

Usually, ScummVM will name the .dll file that is missing, but in some cases, all you get is a quite unspecific error code "0xc000007b". When you get this error code, please double-check if you copied all necessary .dll files.