STEAM GROUP
Morrowind Multiplayer mwmulti
STEAM GROUP
Morrowind Multiplayer mwmulti
103
IN-GAME
1,501
ONLINE
Founded
July 8, 2016
Language
English
All Discussions > Help > Topic Details
 This topic has been pinned, so it's probably important
David C. Oct 9, 2016 @ 9:20am
Windows: how to compile and run from the source code
This guide was last updated on the 14th of October 2017. If any of the information here is now out of date, please let me know so I can update it.


Introduction

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[en.wikipedia.org] 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[msdn.microsoft.com] 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[en.wikipedia.org] using GCC.


What are MSYS2 and MinGW-w64?

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.


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

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.


Part 1: Building the client with Visual C++

1. 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:

https://wiki.openmw.org/index.php?title=User:Gblues

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[github.com] 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[bugs.openmw.org].

OpenMW's recommended version of OSG is 3.4.0, whose source files you can get from here[github.com].

You can also try using OSG 3.5.5's source files from here[github.com], like I do in my own builds of TES3MP.


2. Download the tes3mp source code from GitHub:

https://github.com/TES3MP/openmw-tes3mp

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 in C:\tes3mp\src and will build it in C:\tes3mp\build

Let's also assume you've placed OpenMW's dependencies in C:\OpenMW\deps and will be placing the tes3mp-only dependencies in C:\tes3mp\deps.


3. One 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:

https://github.com/TES3MP/RakNet

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:

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

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:

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

And put them here:

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

While you're at it, you'll notice that the following folder has also been created and populated with files:

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

You'll want to move its contents here:

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


4. 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:

https://sourceforge.net/projects/luabinaries/files/5.1.5/Windows%20Libraries/Static/lua-5.1.5_Win64_vc14_lib.zip/download

Put the lua5.1.lib file here:

C:\tes3mp\deps\lua\lib

Then move the contents of the include folder to this location:

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

That will make CMake-GUI happy when you leave the server enabled in it.


5. 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:

http://download.qt.io/official_releases/qt/5.6/5.6.2/qt-opensource-windows-x86-msvc2015_64-5.6.2.exe

Install it and, assuming you've used its default installation folder, set the following environment variable:

QTDIR => C:\Qt\Qt5.6.2


6. 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:

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

You will then get an error about MyGUI not being found. Set these values:

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

You will then get an error about some SDL2 files not being found. Set these values:

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

You will then get an error about Lua not being found. Set these values:

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

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:

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

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.


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


8. In your Solution Explorer, right click on tes3mp and select Build.

If all is well, you should end up with a nice and shiny tes3mp.exe in this folder:

C:\tes3mp\build\Release


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

1. Get the MSYS2 installer for 64-bit Windows from here and use it:

http://www.msys2.org


2. Go to the folder where you've installed MSYS2 and run msys2.exe

In the shell window that opens, put in the following command to update MSYS2's package database and core system packages:

pacman -Syu

Afterwards, close msys2.exe, start it up again and type in the following to finish the update:

pacman -Su


3. Now you have to install the various dependencies needed for the tes3mp server. Type in the following:

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


4. Close msys2.exe, start up mingw64.exe and 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:

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

Use the following commands to build 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

Type this in to move the RakNet library to where it can be found automatically:

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


5. Set up an environment variable for RakNet:

export RAKNET_ROOT=~/raknet

Then move back to your home folder:

cd ../..


6. 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.1

To fix that, set LUA_INCLUDE_DIR manually like this:

export LUA_INCLUDE_DIR=/mingw64/include/lua5.1


7. Clone tes3mp's repository:


Use the following commands to build tes3mp's server:

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


8. Assuming you've used default paths, you should now have a working tes3mp-server.exe at the following location:

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

Before running it, download tes3mp's PluginExamples[github.com] – 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:

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

Open up tes3mp-server-default.cfg in the same folder and change this line:

home = ~/ClionProjects/PS-dev

Into this:

home = ./mp-stuff

The server should now run fine.
Last edited by David C.; Oct 13, 2017 @ 3:14pm
< >
Showing 1-7 of 7 comments
David C. Oct 14, 2016 @ 8:55am 
Feel free to reply here if anything is unclear or confusing and I'll try to help.
Hey, David

So, I recompiled from the source this morning, and I ran into an error: mClient is undefined in windowcaption.cpp . Do you have any tips on how to solve this?

Edit: Think I found the problem. Anything above release 3.2.2 breaks it in some way, according to the OpenMW forums. I'll give this a shot.
Last edited by Starstilanx/Verinax; May 30, 2017 @ 7:39pm
David C. May 30, 2017 @ 7:50pm 
Starstilanx/Verinax, I did write the following in the guide:

Also note that simply cloning the MyGUI repo is not enough, because a recent commit[github.com] has broken MyGUI's compatibility with OpenMW. You will have to revert your local MyGUI repo to this commit[github.com] before building it.
Originally posted by David C.:
Starstilanx/Verinax, I did write the following in the guide:

Also note that simply cloning the MyGUI repo is not enough, because a recent commit[github.com] has broken MyGUI's compatibility with OpenMW. You will have to revert your local MyGUI repo to this commit[github.com] before building it.

Wow, I fail, hah. That's what I get for working on this at 2AM last night.

Thank you, David. I appreciate the effort you put into this.
Jul 16, 2017 @ 5:51pm 
Hi! I was following this guide and wondering if you could help me with an issue I'm having. I followed the instructions in Gblues' guide and got OpenMW to work fine, then followed the rest of the instructions here to make the tes3mp.exe file. Unfortunately, I keep getting these errors when I try to run the executable:
"The code execution cannot proceed because ot20-OpenThreads.dll was not found. Reinstalling the program may fix this problem.
The code execution cannot proceed because osg130-osgParticle.dll was not found. Reinstalling the program may fix this problem.
The code execution cannot proceed because osg130-osg.dll was not found. Reinstalling the program may fix this problem.
The code execution cannot proceed because osg130-osgUtil.dll was not found. Reinstalling the program may fix this problem."
I've reinstalled OpenSceneGraph twice and the issue keeps cropping up when I try to run the executable. Do you know what I can do to fix this? Thanks.

David C. Jul 16, 2017 @ 9:24pm 
Have you moved all those DLL files to the folder with the executable, as instructed by the guide?
Jul 17, 2017 @ 7:35am 
Oh, I must have missed that step. That explains it. Thanks. I was able to get the client working after that.
< >
Showing 1-7 of 7 comments
Per page: 15 30 50

All Discussions > Help > Topic Details