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

Jump to navigation Jump to search
(Clarify 32-bit vs 64-bit)
m
Line 25: Line 25:
For i686 (32-bit executable and MinGW), type the following in the MSYS2 terminal to automatically install all packages/libraries needed to compile ScummVM:
For i686 (32-bit executable and MinGW), type the following in the MSYS2 terminal to automatically install all packages/libraries needed to compile ScummVM:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
pacman -S --needed --noconfirm base-devel git mingw-w64-i686-{a52dec,ccache,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}
pacman -S --needed --noconfirm base-devel git mingw-w64-i686-{a52dec,ccache,cairo,curl-winssl,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}
</syntaxhighlight>
</syntaxhighlight>


For x86_64 (64-bit executable and MinGW), type the following in the MSYS2 terminal to automatically install all packages/libraries needed to compile ScummVM:
For x86_64 (64-bit executable and MinGW), type the following in the MSYS2 terminal to automatically install all packages/libraries needed to compile ScummVM:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
pacman -S --needed --noconfirm base-devel git mingw-w64-x86_64-{a52dec,ccache,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}
pacman -S --needed --noconfirm base-devel git mingw-w64-x86_64-{a52dec,ccache,cairo,curl-winssl,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}
</syntaxhighlight>
</syntaxhighlight>


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 modified curl package ===
The default curl version shipped with MSYS2 relies on an external certificate bundle for verifying SSL/TLS certificates. While this works fine in the mingw-w64 shell itself, it will break SSL verification outside the mingw-w64 shell. Since our cloud integration features rely on a working SSL implementation, we need to build our own curl release using the winssl backend instead. WinSSL - as the name implies - is the SSL/TLS library shipped withing Windows itself, so we can rely on the Windows certificate store.
Thanks to the PKGBUILD already provided by the MSYS2/Mingw-w64 developers, this is pretty straight forward.
First, clone the repository containing the mingw-w64 package files in a seperate directory:
git clone <nowiki>https://github.com/msys2/MINGW-packages</nowiki>
Now, we need to modify the file <code>mingw-w64-curl/PKGBUILD</code> which contains all the instructions <code>makepkg</code> uses for building the final package. At the beginning of the file, select the winssl variant instead of the default openssl version.
#_variant=-openssl
_variant=-winssl
#_variant=-gnutls
Since support for METALINK seems to be broken at the moment (and we don't need it), modify the PKGBUILD file as shown below:
  79   if [ "${_variant}" = "-winssl" ]; then
...
  86     _variant_config+=("--without-librtmp")
  87     _variant_config+=("--without-libmetalink")
Finally, we can build and install the modified package.
Before building the package itself, you need to add the GPG key of the curl developer to your local keychain, so makepkg can validate the package. Under no circumstances you should try skipping the signature checks since you really, REALLY don't want a malicious curl package on your system.
  gpg --recv-keys 5CC908FDB71E12C2
Enter the <code>mingw-w64-curl</code> directory and start the build process:
  makepkg --syncdeps
Depending on your system, building the package should only take a couple of minutes. Finally, install the resulting package using pacman:
  pacman -U mingw-w64-x86_64-curl-winssl-7.xx.0-1-any.pkg.tar.zst
If you have installed curl previously, you need to accept the removal of the previous package since you can't have multiple variants installed at the same time.


== Let's get compiling! ==
== Let's get compiling! ==
Line 76: Line 46:
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:
   strip scummvm.exe
   strip scummvm.exe
Please note that using this step is not necessary if you build a distributable package.


That's it, you successfully compiled ScummVM from the source code.
That's it, you successfully compiled ScummVM from the source code.
Line 83: Line 55:
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 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:
If you intend to build a ScummVM package that includes all the necessary files, you can build such a redistributable package by using
<code>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</code>
 
  make win32dist-mingw WIN32PATH=<target>
 
where <code><target></code> specifies the directory that will contain the redistributable packages.


== Common Issues ==
== Common Issues ==