SHARE
TWEET
ScummVM w/ FluidSynth
a guest
Mar 21st, 2017
142
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- Building FluidSynth with MSVC 2017
- ----------------------------------
- FluidSynth, sadly, requires GLib, which is quite tricky to build on MSVC. To be precise, it needs glib itself, and gthread. To build it, you need cmake and pkg-config.
- GLib itself is also not easy as it requires libiconv and libintl, for both of which no official MSVC support exists anymore. Fortunately there's a project available on github which helps with that.
- Some files also have to be patched manually.
- I tried all this with a 64-bit build, both in Debug and Release runtimes, and it worked just fine. For x86, your mileage may vary (but I guess it will be equally easy).
- IMPORTANT: For each library you build, make SURE that you select the proper runtime in the Code Generation settings of your project.
- The runtime MUST match between all your libraries and your main executable, otherwise you WILL get strange crashes.
- For ScummVM, the default is "Multi-Threaded DLL" for release builds and "Multi-Threaded Debug DLL" for debug builds. I won't mention this in each step, but you need to change it accordingly for every library.
- Personally, I'm using "Multi-Threaded" and "Multi-Threaded Debug" runtimes, this works just as well (as long as you edit every single project you build)
- Step-by-step instructions
- -------------------------
- 1) Installing CMake
- This should be easy, as probably any fairly recent version of CMake should work. I'm using CMake 3.7.2 from here:
- https://cmake.org/files/v3.7/cmake-3.7.2-win64-x64.msi
- 2) Installing pkg-config
- This is also easy, as it is only required by the CMake build of FluidSynth to find glib and gthread, and we'll be hacking out that check anyway :) But since it was easier to just change that single library check to an optional one instead of removing the entire pkg-config call, we'll just go with that. YMMV, and you might skip this step if you hack the CMakeLists.txt a bit.
- Grab those three files and extract all the EXE and DLL files from the "bin/" directory in the ZIP file into a directory that is in your path:
- http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config_0.26-1_win32.zip
- http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.28/glib_2.28.8-1_win32.zip
- http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime_0.18.1.1-2_win32.zip
- It should be pkg-config.exe, intl.dll, libgio-2.0-0.dll, libglib-2.0-0.dll, libgmodule-2.0-0.dll, libgobject-2.0-0.dll and libgthread-2.0-0.dll
- Note that these are built with MinGW and cannot be used directly with anything built with MSVC, thus we'll be rebuilding some of them further down anyway. I just couldn't find a way to get pkg-config to compile from source so we use a binary here...
- 3) Building libintl/libiconv
- There is a project on GitHub that helps with this step. Clone the following repo somewhere: https://github.com/kahrl/gettext-msvc
- Then, grab the following two packages and unpack them into the gettext-msvc directory, as described by the README in that project:
- http://ftp.gnu.org/gnu/gettext/gettext-0.19.4.tar.gz
- http://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz
- After that, you can open the provided solution (gettext.sln) and build it in MSVC. You should get the following files in Debug-x64 and Release-x64:
- libiconv.dll
- libintl.dll
- libiconv.lib
- libintl.lib
- ...Copy those files into your lib/ directory so that MSVC can find them
- Also, copy the following file to your include/ directory (noted here as %INCLUDE%) as libintl.h:
- gettext-0.19.4/gettext-runtime/intl/libintl.glibc -> %INCLUDE%/libintl.h
- You need to patch that file so that it will be usable, since MSVC doesn't contain a features.h include file:
- ------------------------------------------------------------------------------
- --- libintl.glibc 2013-01-09 05:01:27.000000000 +0100
- +++ libintl.h 2017-03-21 00:59:49.619678700 +0100
- @@ -20,7 +20,12 @@
- #ifndef _LIBINTL_H
- #define _LIBINTL_H 1
- -#include <features.h>
- +//#include <features.h>
- +#define __const const
- +#define __THROW
- +#define __BEGIN_DECLS
- +#define __END_DECLS
- +#define __attribute_format_arg__(x)
- /* We define an additional symbol to signal that we use the GNU
- implementation of gettext. */
- ------------------------------------------------------------------------------
- 4) Building GLib
- I'm using GLib 2.49.7, available from here:
- https://download.gnome.org/sources/glib/2.49/glib-2.49.7.tar.xz
- Unpacking this on Windows is left as an exercise for the reader ;-)
- Fortunately, for GLib, there are solution files provided that we can use. They are in glib-2.49.7/build/win32/vs14 (they work just fine with vs2017)
- In this case there are multiple build targets, and we should use the ones that are called "Debug_BundledPCRE" or "Release_BundledPCRE", otherwise we'd have to build PCRE ourselves first.
- As mentioned before, we only need glib and gthread. Edit the properties of these projects, to point to the include/ and lib/ directories that contain our libintl/libiconv libraries and includes.
- Build the glib and gthread projects.
- Make sure that there is a "config.h" file generated by the build step, because that file is required for compiling. It should be generated from the config.h.win32.in. You might need a Python interpreter for this step (I didn't really pay attention on how the file was generated but there are some python calls in some custom build steps in the projects).
- Copy glib/glib.h ->%INCLUDE%/glib.h
- Copy glib/*.h -> %INCLUDE&/glib/*.h
- Copy glib/deprecated/*.h -> %INCLUDE%/glib/deprecated/*.h
- Copy build/win32/vs14/{Debug,Release}/{x64,x86}/bin/*.{dll,lib} to your library directory and somewhere into your path (or to where ScummVM.exe will be)
- Note that the DLLs will be called glib-2-vs14.dll (and not just glib-2.dll), if you want to change that you have to edit the project files. I just left it as is
- There should be 2 DLL and LIB files: glib-2-vs14.dll, gthread-2-vs14.dll, glib-2.0.lib and gthread-2.0.lib
- 5) build FluidSynth
- Check out FluidSynth from their SF page:
- git checkout https://git.code.sf.net/p/fluidsynth/code-git fluidsynth
- Edit the CMakeLists.txt file and change:
- pkg_check_modules ( GLIB REQUIRED glib-2.0>=2.6.5 gthread-2.0>=2.6.5 )
- to:
- pkg_check_modules ( GLIB glib-2.0>=2.6.5 gthread-2.0>=2.6.5 )
- This will skip the mandatory GLib library search. You still need GLib to compile FluidSynth and you have to provide it manually in the project
- Create a subdirectory "build" under your checkout path, change into it and type
- cmake -G "Visual Studio 15 2017 Win64" ..
- (for 64-bit) or
- cmake -G "Visual Studio 15 2017 " ..
- (for 32-bit).
- CMake should run, find its required libraries and generate a *.sln file for you. You can ignore any warnings that pop up about missing features and stuff like that.
- Open the solution file, and edit the header file called "config_win32.h" for the libfluidsynth project. In it, comment out or delete the line that says "#define snprintf _snprintf", since apparently, since MSVC2017, Microsoft finally provides its own snprintf function :)
- Fix the project link settings to link against glib-2.0.lib and gthread-2.0.lib (properties, linker, input, additional dependencies). Also make sure that your include files will be found
- After building libfluidsynth (you can also build the fluidsynth project, this will create the fluidsynth.exe executable if you have everything set up correctly) you should have a libfluidsynth.lib and libfluidsynth.dll (or libfluidsynth_debug.lib and libfluidsynth_debug.dll)
- 6) Build ScummVM
- Either re-run create_project with "--enable-fluidsynth" (?) or just add it manually (if you modified your project already a bit, like I did):
- - add USE_FLUIDSYNTH as preprocessor definition in the "scummvm" project
- - add the 2 files "gui/fluidsynth-dialog.{cpp,h}" to the ScummVM project
- Make sure that all your include files and library file can be found, compile, wait, copy the required DLLs (either debug or release) to where your ScummVM executable is, and enjoy!
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

