Windows: how to compile and run from the source code [OUTDATED since December 2018]

Introduction

[en.wikipedia.org]

[msdn.microsoft.com]

[en.wikipedia.org]

What are MSYS2 and MinGW-w64?

Why do I still need to build the client with Visual C++?

Part 1: Building the client with Visual C++

[github.com]

[bugs.openmw.org]

[github.com]

[github.com]

RAKNET_ENABLE_DLL = OFF RAKNET_ENABLE_LIBCAT_SECURITY = OFF RAKNET_ENABLE_SAMPLES = OFF RAKNET_ENABLE_STATIC = ON

C:\tes3mp\deps\build\RakNet\lib\Debug\RakNetLibStatic.lib C:\tes3mp\deps\build\RakNet\lib\Release\RakNetLibStatic.lib

C:\tes3mp\deps\RakNet\lib\Debug\RakNetLibStatic.lib C:\tes3mp\deps\RakNet\lib\Release\RakNetLibStatic.lib

C:\tes3mp\deps\build\RakNet\include\raknet

C:\tes3mp\deps\RakNet\include\raknet

C:\tes3mp\deps\lua\lib

C:\tes3mp\deps\lua\include\lua

QTDIR => C:\Qt\Qt5.6.2

RakNet_INCLUDES = C:/tes3mp/deps/RakNet/include RakNet_LIBRARY_DEBUG = C:/tes3mp/deps/RakNet/lib/Debug/RakNetLibStatic.lib RakNet_LIBRARY_RELEASE = C:/tes3mp/deps/RakNet/lib/Release/RakNetLibStatic.lib

MyGUI_INCLUDE_DIRS = C:/OpenMW/deps/mygui/sdk/include/MYGUI MyGUI_LIBRARY = C:/OpenMW/deps/mygui/sdk/lib/Release/MyGUIEngine.lib

SDL2_LIBRARY = C:/OpenMW/deps/SDL2/lib/SDL2.lib SDL2MAIN_LIBRARY = C:/OpenMW/deps/SDL2/lib/SDL2main.lib

LUA_LIBRARY = C:/tes3mp/deps/lua/lib/lua51.lib LUA_INCLUDE_DIR = C:/tes3mp/deps/lua/include

ZLIB_LIBRARY_RELEASE = C:/OpenMW/deps/3rdparty/x64/lib/zlib.lib ZLIB_INCLUDE_DIR = C:/OpenMW/deps/3rdparty/x64/include

C:\tes3mp\build\Release

Part 2: Building the server with GCC in MinGW-w64

pacman -Syu

pacman -Su

pacman -S make git unzip mingw-w64-x86_64-gcc mingw-w64-x86_64-boost mingw-w64-x86_64-make mingw-w64-x86_64-cmake mingw-w64-x86_64-lua51 mingw-w64-x86_64-OpenSceneGraph

C:\msys64\home\[Username]\raknet

cd raknet mkdir build cd build cmake .. -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DRAKNET_ENABLE_DLL=OFF -DRAKNET_ENABLE_LIBCAT_SECURITY=OFF -DRAKNET_ENABLE_SAMPLES=OFF -DRAKNET_ENABLE_STATIC=ON make

mkdir ../lib/RakNetLibStatic cp ./lib/libRakNetLibStatic.a ../lib/RakNetLibStatic

export RAKNET_ROOT=~/raknet

cd ../..

export LUA_INCLUDE_DIR=/mingw64/include/lua5.1

cd openmw-tes3mp mkdir build cd build cmake .. -G "MSYS Makefiles" -DBUILD_BROWSER=OFF -DBUILD_BSATOOL=OFF -DBUILD_ESMTOOL=OFF -DBUILD_ESSIMPORTER=OFF -DBUILD_MWINIIMPORTER=OFF -DBUILD_INIIMPORTER=OFF -DBUILD_LAUNCHER=OFF -DBUILD_MYGUI_PLUGIN=OFF -DBUILD_OPENCS=OFF -DBUILD_OPENMW=OFF -DBUILD_WIZARD=OFF make

C:\msys64\home\[Username]\openmw-tes3mp\build\tes3mp-server.exe

[github.com]

C:\msys64\home\[Username]\openmw-tes3mp\build\mp-stuff

home = ~/ClionProjects/PS-dev

home = ./mp-stuff

This guide was last updated on the 14th of October 2017.tes3mp is basically OpenMW plus multiplayer, but there's a catch: the way its server code was written makes it tricky to compile on Windows for the time being.There are several versions of C++. OpenMW and the tes3mp client both use C++11, but the tes3mp server uses C++14 because of a few extra features in it that allow the code to have a cleaner structure.Unfortunately, one of these features from C++14 – commonly referred to as "Extended constexpr" – is not currently supported by Visual C++, the compiler of choice for Windows builds of OpenMW.I wasn't around when the decision was made to use that feature, but I am reluctant to rethink the server's structure in order to remove it, especially seeing as GCC – the Linux compiler of choice – has no issues with it. As such, I prefer to wait until Visual C++ supports it, even if it means jumping through some hoops in the meantime.Essentially, you will have to build the tes3mp client in Microsoft Visual Studio 2017 using Visual C++, and then you will have to build the tes3mp server separately in MSYS2 and MinGW-w64 using GCC.MinGW-w64 is a software development environment that provides you with a Windows version of the GCC compiler.MSYS2 is a command-line shell that lets you use various GNU tools on Windows.With them, you can build the tes3mp server on Windows similarly to how you would build it on Linux.OpenMW uses a lot of libraries from other open source projects, such as Boost, FFMPEG, Bullet3, MyGUI, OpenSceneGraph and so on.When you build OpenMW on an operating system using a certain compiler, you need to also provide it with all of those dependencies built for that operating system using the same compiler.In other words, if you build OpenMW on Windows with Visual C++, you need to provide it with every single dependency as built on Windows with Visual C++. If you build it on Linux with GCC, you need to provide it with every dependency as built on Linux with GCC. Both of these scenarios are relatively straightforward, with the dependencies either readily available or easy to build.If you build OpenMW on Windows with MinGW-w64, you need every dependency as built on Windows with MinGW-w64. Here's the problem: some dependencies, and their own dependencies, are not available to you in this scenario.It's ultimately easier to just supply the Visual C++ client with its easily-obtained Visual C++ dependencies, and the MinGW-w64 server with the minimal MinGW-w64 dependencies it requires, than to build every OpenMW dependency for MinGW-w64.The tes3mp client is a modified version of OpenMW and requires all of its dependencies. As such, start out by following this excellent guide by Gblues for building OpenMW:The last time you have to use CMake in that guide, you will actually get more errors than are mentioned there. Refer to step 6 of this guide for fixes to them.The links under "FreeType, GIFLIB, GLUT, libCURL, libJPEG, libPNG, libTIFF, minizip, and zlib" may be a bit outdated, which is why you should use the ones here instead.Also note that you should not clone the OpenSceneGraph repo as suggested in that guide, because OSG 3.5.6 causes a problem with highlighting items as noted here OpenMW's recommended version of OSG is 3.4.0, whose source files you can get from here You can also try using OSG 3.5.5's source files from here , like I do in my own builds of TES3MP.Download the tes3mp source code from GitHub:For simplicity's sake, let's assume you're using similar folder paths to those in the guide by Gblues, and have therefore put the source code inand will build it inLet's also assume you've placed OpenMW's dependencies inand will be placing the tes3mp-only dependencies inOne additional library required by the tes3mp client is RakNet. Because its official repository has not been updated in a long time, download our fork of it that makes it work with Visual Studio 2017 out of the box:Use CMake to generate the Visual Studio projects for RakNet, similarly to how you've done it for Bullet3, MyGUI and OpenSceneGraph.Use the following values in CMake-GUI:Open up RakNet.sln in Visual Studio and do both a Debug and a Release build of it.You now want to find these files:And put them here:While you're at it, you'll notice that the following folder has also been created and populated with files:You'll want to move its contents here:Although you won't be building the server in Visual Studio 2017, it's still useful to be able to read and edit the server code in it. To that end, get the binaries for the Lua scripting language – a server-only dependency – from here:Put the lua5.1.lib file here:Then move the contents of the include folder to this location:That will make CMake-GUI happy when you leave the server enabled in it.If you wish to build tes3mp's launcher and browser, you will also need to install Qt 5.Get Qt 5.6.2 for Visual Studio 2015 (which also works with Visual Studio 2017) from here:Install it and, assuming you've used its default installation folder, set the following environment variable:Configure and generate Visual Studio projects for tes3mp with CMake, similarly to how you've done it for regular OpenMW.With Qt 5 installed, you can enable BUILD_LAUNCHER, BUILD_OPENCS and BUILD_WIZARD. Even though you can't build the server, make sure you leave BUILD_OPENMW_MP turned on so you'll have access to the server code in Visual Studio.The first time you click on Configure, you'll get an error about RakNet not being found. Fix that by setting these values:You will then get an error about MyGUI not being found. Set these values:You will then get an error about some SDL2 files not being found. Set these values:You will then get an error about Lua not being found. Set these values:Finally, you will get an error about ZLIB not being found. Make sure the Advanced checkbox is enabled in CMake-GUI and then set these values:You will also be notified of Doxygen not being found, but you can safely ignore that. Click on Generate and the Visual Studio project should be good to go.Open up the newly generated OpenMW.sln file in Visual Studio 2017.Click on Build -> Configuration Manager and set the "Active solution configuration" to Release.In your Solution Explorer, right click on tes3mp and select Build.If all is well, you should end up with a nice and shinyin this folder:Get the MSYS2 installer for 64-bit Windows from here and use it:Go to the folder where you've installed MSYS2 and runIn the shell window that opens, put in the following command to update MSYS2's package database and core system packages:Afterwards, close, start it up again and type in the following to finish the update:Now you have to install the various dependencies needed for the tes3mp server. Type in the following:Close, start upand use that from now on.We need to build RakNet separately for the server, so type in the following to clone RakNet's repository:Assuming you've used the default installation location for MSYS2, that means you will now have a copy of RakNet's repo at the following path:Use the following commands to build RakNet:Type this in to move the RakNet library to where it can be found automatically:Set up an environment variable for RakNet:Then move back to your home folder:When generating CMake files for tes3mp in MSYS2, LUA_INCLUDE_DIR gets set to the wrong path, and the header of MSYS2's default Lua version is loaded instead of the one for Lua 5.1To fix that, set LUA_INCLUDE_DIR manually like this:Clone tes3mp's repository:Use the following commands to build tes3mp's server:Assuming you've used default paths, you should now have a workingat the following location:Before running it, download tes3mp's PluginExamples – essentially, tes3mp's default Lua scripts – and place them somewhere easy to reach. For simplicity, let's assume you're placing the contents of that repo here:Open upin the same folder and change this line:Into this:The server should now run fine.