Difference between revisions of "Compiling ScummVM/Visual Studio"

From ScummVM :: Wiki
Jump to navigation Jump to search
(Update MSVC compilation instructions.)
(→‎Generating the Project Files: Add info on using FluidLite instead of FluidSynth when using the prebuilt libraries)
 
(22 intermediate revisions by 7 users not shown)
Line 1: Line 1:
== Compiling ScummVM with Visual Studio under Windows ==
== Installing the needed software and libraries ==


Compiling ScummVM with Visual Studio is not an awfully hard task. It is however slightly more complicated than using MinGW. We guide you through the steps to make ScummVM compile with Visual Studio on this page.
In this page, we guide you through the steps to compile ScummVM with Visual Studio.


== Things needed ==
=== Visual Studio ===
You can get the free Community version of Visual Studio [https://visualstudio.microsoft.com/vs/ here].
Professional Visual Studio versions are working fine too.


=== Visual Studio ===
When installing Visual Studio 2017 or later, make sure to select the "Desktop Development with C++" workload.
There exists a free Community version of Visual Studio 2015 [https://www.visualstudio.com/en-US/products/visual-studio-express-vs here] that can be used.
Professional Visual Studio 2015 versions are working fine too.


We do support older versions of Visual Studio too. However, on this page we focus on building ScummVM with Visual Studio 2015. Building ScummVM with older Visual Studio versions can require additional work not described on this page.
Building ScummVM with Visual Studio versions older than 2015 is not supported anymore.


=== Needed Libraries ===
=== Needed Libraries ===
ScummVM relies on third-party libraries to implement certain functionality. Some of these libraries are required, like for example SDL, others are optional, like for example libtheora. We supply a set of prebuilt libraries for Visual Studio 2015. These have been build on Windows 8.1 using the Visual Studio 2015 Community Edition. The libraries can be found [http://www.scummvm.org/frs/build/scummvm_libs_2015.zip here].
ScummVM relies on third-party libraries for common features, such as MP3 decoding. Some of these libraries, like SDL, are required, whereas others like libtheora are optional.
 
We supply a set of prebuilt libraries for Visual Studio 2015 and later, which can be found [https://downloads.scummvm.org/frs/build/scummvm_libs_2015.zip here].
 
These libraries have been built on Windows 8.1 using the Visual Studio 2015 Community Edition.


=== Installing Libraries ===
When compiling for Windows on ARM, you will need the download the [https://devblogs.microsoft.com/directx/announcing-the-opencl-and-opengl-compatibility-pack-for-windows-10-on-arm/ OpenGL Compatibility Pack]. An updated version of the compatibility pack can be found in the Microsoft Store [https://apps.microsoft.com/detail/9nqpsl29bfff?ocid=pdpshare&hl=en-us&gl=US here].
The easiest way to make Visual Studio find the supplied libraries is by using the environment variable "SCUMMVM_LIBS". We describe this method now.
To make it work you have to follow these steps:
* Unzip the library zip to a directory of your choice. For example, you can unzip them into "C:\Users\YourUsername\Documents\scummvm_libs_2015".
* Go to Control Panel -> Environment Variables and set up a new variable "SCUMMVM_LIBS" with a value of the path you extracted the zip in. It is important that you do point the variable to the folder containing the "bin", "include", and "lib" directories.


=== Manually Building Libraries ===
If you want to build libraries for use with Visual Studio yourself, please refer to the [[Compiling_ScummVM/Visual_Studio/Compiling_Libraries|instructions for compiling the libraries yourself]].
If you want to build libraries for use with Visual Studio yourself, please refer to the [[Compiling_ScummVM/Visual_Studio/Compiling_Libraries|instructions for compiling the libraries yourself]].
=== Installing Libraries ===
The easiest way to make Visual Studio find the supplied libraries is by using the environment variable <code>SCUMMVM_LIBS</code>. You can set it by performing the following steps:
* Unzip the library zip to a directory of your choice, for example <code>C:\Users\YourUsername\Documents\scummvm_libs_2015</code>.
* Go to Start Menu > Control Panel > System > Advanced Settings > Environment Variables (or <code>Win</code>+<code>R</code> and then <code>SystemPropertiesAdvanced.exe</code>) and add a new variable <code>SCUMMVM_LIBS</code> with a value of the path you extracted the zip in. It is important that you do point the variable to the folder containing the <code>bin\</code>, <code>include\</code>, and <code>lib\</code> directories.


== Preparing the Project Files ==
== Preparing the Project Files ==
Line 27: Line 31:
=== Building create_project ===
=== Building create_project ===


ScummVM uses a configure/Make based build system. We feature a tool to generate Visual Studio project files from this build system. The first steep you need to take is building this tool called "create_project".
ScummVM uses a configure/Make based build system. We have a tool to generate Visual Studio project files from this build system. The first step you need to take is building this tool called <code>create_project.exe</code>.


First, open the solution file "devtools\create_project\msvc14\create_project.sln". Then simply build the solution. The project file should automatically assure that the resulting "create_project.exe" is copied to "dists\msvc14". If not, you will have to copy it yourself.
First, open the solution file <code>devtools\create_project\msvc\create_project.sln</code> (either from the File Explorer or from the File > Open project/solution menu). Then simply build the solution, with Build > Build solution. If this doesn't work, make sure that the Visual Studio C++ tools have been properly set up, as [[#Visual_Studio|explained above]].
 
The project file should automatically assure that the resulting <code>create_project.exe</code> is copied to <code>dists\msvc\</code>.


=== Generating the Project Files ===
=== Generating the Project Files ===


Simply run the batch script "dists/msvc14/create_msvc14.bat". It will guide you through configuring ScummVM.
Simply run the batch script <code>dists/msvc/create_msvc.bat</code>. It will guide you through configuring ScummVM.
 
'''IMPORTANT''': You will have to re-generate the project files whenever new source files have been added to or removed from the configure/Make based build system. When you add new files to ScummVM, you will ''have'' to add them to the respective <code>module.mk</code> file to assure ScummVM still builds fine with the configure/Make based build system.


'''IMPORTANT''': You will have to re-generate the project files whenever new source files have been added to or removed from the configure/Make based build system. When you add new files to ScummVM, you will ''have'' to add them to the respective "module.mk" file to assure ScummVM still builds fine with the configure/Make based build system.
==== In case of missing dependency ====
When using the prebuilt libraries, you might be missing a dependency, and compiling could give an error complaining about a missing header, e.g. <code>fluidsynth.h</code>. You can work around this by calling <code>create_project.exe</code> directly, and passing additional arguments to enable/disable features. For example, to use FluidLite (which is included in the prebuilt libraries) instead of FluidSynth, you can create a project for all engines and FluidLite like this:<syntaxhighlight lang="powershell">
cd dists\msvc
.\create_project ..\.. --msvc --enable-fluidlite
</syntaxhighlight>


== Compiling ScummVM ==
== Compiling ScummVM ==
Line 41: Line 53:
If you followed all the steps, you are now ready to compile ScummVM with Visual Studio. Congratulations!
If you followed all the steps, you are now ready to compile ScummVM with Visual Studio. Congratulations!


Simply open the generated solution file in "dists\msvc14\scummvm.sln". Now you can ask it to build the desired configuration. By default it will build a debug configuration which is ideal to hack on ScummVM.
Simply open the generated solution file in <code>dists\msvc\scummvm.sln</code>. Now you can ask it to build the desired configuration. By default it will build a debug configuration which is ideal to hack on ScummVM.
 
'''IMPORTANT''': If you get errors about missing DLLs, you'll need to copy them to a location Windows picks up to run the resulting binary. The easiest way to do this is to place the DLL files in the directory where <code>scummvm.exe</code> is. There are multiple folders to choose from, depending on your build configuration. For example, if you build a Win32 Debug configuration, you will need to copy them from <code>SCUMMVM_LIBS\lib\x86\Debug\</code> to <code>dists\msvc\Debugx86\</code>.
 
NOTE: Several people have had errors about structure packing under Visual Studio 2019. In such cases, you need to update [https://github.com/libsdl-org/SDL/releases SDL2] with the latest version.
 
== Compiling with Console/Text Output ==


'''IMPORTANT''': You'll need to copy the matching SDL.dll file to a location Windows picks up to run the resulting binary. The easiest way to do this is to place the SDL.dll file in the directory where scummvm.exe is. There are multiple SDL.dll files to choose from, depending on your build configuration. Simply pick the right one from the prebuilt libraries. For example, if you build a Win32 Debug configuration, you will need to use "libs/x86/Debug/SDL.dll".
By default ScummVM is compiled as a Windows subsystem application with no console output. If you need the console, you can do one of the following:
* In the <code>create_project</code> command, add <code>--enable-text-console</code>.
* In the Project Options for the ScummVM project, go to the Linker | System | SubSystem line, and change the <code>/SUBSYSTEM:WINDOWS</code> option to <code>/SUBSYSTEM:CONSOLE</code>

Latest revision as of 09:44, 17 November 2024

Installing the needed software and libraries

In this page, we guide you through the steps to compile ScummVM with Visual Studio.

Visual Studio

You can get the free Community version of Visual Studio here. Professional Visual Studio versions are working fine too.

When installing Visual Studio 2017 or later, make sure to select the "Desktop Development with C++" workload.

Building ScummVM with Visual Studio versions older than 2015 is not supported anymore.

Needed Libraries

ScummVM relies on third-party libraries for common features, such as MP3 decoding. Some of these libraries, like SDL, are required, whereas others like libtheora are optional.

We supply a set of prebuilt libraries for Visual Studio 2015 and later, which can be found here.

These libraries have been built on Windows 8.1 using the Visual Studio 2015 Community Edition.

When compiling for Windows on ARM, you will need the download the OpenGL Compatibility Pack. An updated version of the compatibility pack can be found in the Microsoft Store here.

If you want to build libraries for use with Visual Studio yourself, please refer to the instructions for compiling the libraries yourself.

Installing Libraries

The easiest way to make Visual Studio find the supplied libraries is by using the environment variable SCUMMVM_LIBS. You can set it by performing the following steps:

  • Unzip the library zip to a directory of your choice, for example C:\Users\YourUsername\Documents\scummvm_libs_2015.
  • Go to Start Menu > Control Panel > System > Advanced Settings > Environment Variables (or Win+R and then SystemPropertiesAdvanced.exe) and add a new variable SCUMMVM_LIBS with a value of the path you extracted the zip in. It is important that you do point the variable to the folder containing the bin\, include\, and lib\ directories.

Preparing the Project Files

Building create_project

ScummVM uses a configure/Make based build system. We have a tool to generate Visual Studio project files from this build system. The first step you need to take is building this tool called create_project.exe.

First, open the solution file devtools\create_project\msvc\create_project.sln (either from the File Explorer or from the File > Open project/solution menu). Then simply build the solution, with Build > Build solution. If this doesn't work, make sure that the Visual Studio C++ tools have been properly set up, as explained above.

The project file should automatically assure that the resulting create_project.exe is copied to dists\msvc\.

Generating the Project Files

Simply run the batch script dists/msvc/create_msvc.bat. It will guide you through configuring ScummVM.

IMPORTANT: You will have to re-generate the project files whenever new source files have been added to or removed from the configure/Make based build system. When you add new files to ScummVM, you will have to add them to the respective module.mk file to assure ScummVM still builds fine with the configure/Make based build system.

In case of missing dependency

When using the prebuilt libraries, you might be missing a dependency, and compiling could give an error complaining about a missing header, e.g. fluidsynth.h. You can work around this by calling create_project.exe directly, and passing additional arguments to enable/disable features. For example, to use FluidLite (which is included in the prebuilt libraries) instead of FluidSynth, you can create a project for all engines and FluidLite like this:

cd dists\msvc
.\create_project ..\.. --msvc --enable-fluidlite

Compiling ScummVM

If you followed all the steps, you are now ready to compile ScummVM with Visual Studio. Congratulations!

Simply open the generated solution file in dists\msvc\scummvm.sln. Now you can ask it to build the desired configuration. By default it will build a debug configuration which is ideal to hack on ScummVM.

IMPORTANT: If you get errors about missing DLLs, you'll need to copy them to a location Windows picks up to run the resulting binary. The easiest way to do this is to place the DLL files in the directory where scummvm.exe is. There are multiple folders to choose from, depending on your build configuration. For example, if you build a Win32 Debug configuration, you will need to copy them from SCUMMVM_LIBS\lib\x86\Debug\ to dists\msvc\Debugx86\.

NOTE: Several people have had errors about structure packing under Visual Studio 2019. In such cases, you need to update SDL2 with the latest version.

Compiling with Console/Text Output

By default ScummVM is compiled as a Windows subsystem application with no console output. If you need the console, you can do one of the following:

  • In the create_project command, add --enable-text-console.
  • In the Project Options for the ScummVM project, go to the Linker | System | SubSystem line, and change the /SUBSYSTEM:WINDOWS option to /SUBSYSTEM:CONSOLE