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

From ScummVM :: Wiki
Jump to navigation Jump to search
m
Line 50: Line 50:


These commands will fetch and install the packages needed for compiling, including (but not limited to) GCC 10.x, GDB, and libwinpthread-git.
These commands will fetch and install the packages needed for compiling, including (but not limited to) GCC 10.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:
<syntaxhighlight lang="bash">
pacman -S mingw-w64-<env>-<library>
</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):
* '''SDL2'''. Mandatory. ''We recently switched to SDL2. SDL 1 is still available as fallback option.''
* '''curl''' and '''SDL2_net'''. Optional, for cloud integration support.
* '''faad2'''. Optional, for AAC support.
* '''flac'''. Optional, for FLAC support.
* '''fluidsynth'''. Optional, for soundfont MIDI support.
* '''freetype'''. Optional, for TTF support.
* '''fribidi'''. Optional, for bidirectional text support for languages that need it (e.g. Hebrew).
* '''libjpeg-turbo'''. Optional, for JPEG support. Required for Groovie 2, Starship Titanic and Wintermute.
* '''libmad'''. Optional, for MP3 support.
* '''libmpeg2-git'''. Optional, for MPEG2 cutscene support.
* '''libogg''' and '''libvorbis'''. Optional, for OGG support.
* '''libpng'''. Optional, for PNG support.
* '''libtheora'''. Optional, for Broken Sword 2.5.
* '''nasm'''. Optional, for faster compile of scalers.
* '''winsparkle'''. Optional, for application updates via the WinSparkle framework.
* '''zlib'''. Optional, for compressed saved games.


=== Let's get compiling! ===
=== Let's get compiling! ===

Revision as of 09:46, 5 April 2021

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 don't recommend using this method if you want to distribute your ScummVM builds. Release builds should be done using MXE if possible, since this allows building an (almost) statically linked executable for easy distribution. Feel free to contact me (rootfather) either via eMail or IRC if you have questions regarding MSYS2/MinGW-w64.


NOTE
Despite the name, MinGW-w64 works on both 32-bit and 64-bit systems, but the latest versions cannot be installed on Windows XP anymore. However, builds produced will still work on Windows XP.

If you need to support older Windows, check out MinGW.


Things needed

Setup MinGW-w64 and MSYS2

You can find MSYS2 on the official webpage and detailed installation instructions on the MSYS2 github wiki.

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 -Syuu

Follow the instructions (one upgrade step may require that the MSYS2 terminal window is closed directly from the window's e(X)it button on the top right. Keep issuing the above command in the MSYS2 terminal until there's no more updating tasks to be done.

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-{a52dec,ccache,curl,cairo,faad2,freetype,flac,fluidsynth,fribidi,glew,libjpeg-turbo,libogg,libvorbis,libmad,libmpeg2-git,libtheora,libpng,nasm,readline,SDL2,SDL2_net,toolchain,winsparkle,zlib,ntldd-git}

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-{a52dec,ccache,curl,cairo,faad2,freetype,flac,fluidsynth,fribidi,glew,libjpeg-turbo,libogg,libvorbis,libmad,libmpeg2-git,libtheora,libpng,nasm,readline,SDL2,SDL2_net,toolchain,winsparkle,zlib,ntldd-git}

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

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.

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

In case you want to distribute your builds to machines without a running MSYS2 installation or if you excluded MSYS2/Mingw-w64 from your PATH, you need to bundle the required .dll files with the executable - otherwise, running ScummVM will fail due to missing dependencies.

In order to copy all required .dll files to the directory where the ScummVM executable is located, run the following command in your build directory:

for i in $(seq 3); do for bin in $(ntldd -R *exe | grep -i mingw | cut -d">" -f2 | cut -d" " -f2); do cp -vu "$bin" . ; done; done