hristoast/site/playing-morrowind-on-gnulinux.html -rw-r--r-- 14.8 KiB View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<h1 id="title">Playing Morrowind on GNU/Linux</h1>

<div id="dates">
  <span>Posted: <time id="post-date">2017-03-21</time> | Updated: <time>2019-11-09</time></span>
</div>

<p><span class="bold">UPDATE:</span> I've since published the <a href="https://git.sr.ht/~hristoast/build-openmw"><code>build-openmw</code></a> script, which is tool to help compile OpenMW with various options (written in Python).  Check that out for an updated way to go!</p>

<p>
  EDIT: Thanks to an awesome community, Void Linux now has packages for Unshield and MyGUI - so those steps can be omitted from your build process... Now back to dancing close to the fire!
</p>

<p>
  <a href="http://en.uesp.net/wiki/Morrowind:Morrowind">The Elder Scrolls III: Morrowind</a> is my favorite video game of all time.  I generally favor games that are a bit older (the SNES-PS1 eras were golden ages for this), but Morrowind sticks with me even 15 years after its release.  And while several pre-packaged modded Morrowind experiences exist for Windows, I submit that the best way to enjoy Morrowind today is on GNU/Linux using <a href="https://openmw.org/">OpenMW</a>.  While not every single feature that is available for modded vanilla Morrowind works in OpenMW (yet), the list of what works is growing with each release - and what does work now is enough to satisfy a newcomer or a seasoned player like myself.
</p>

<p id="post-excerpt">
  In this entry I'll discuss what is needed to run Morrowind via OpenMW, and how to get it -- but also in a way that's reproducible and mostly independent of your distribution.  I'm not going to go into too much detail about mods (maybe in a part 2 perhaps) but I will go over some general recommendations.  Let's go, outlander!
</p>

<div id="toc"></div>

<h3>The game</h3>

<p>
  There are several options for purchasing Morrowind nowadays, I strongly recommend the copy that's <a href="https://www.gog.com/game/the_elder_scrolls_iii_morrowind_goty_edition">available over at gog.com</a> for obvious reasons.  Install the game with wine, no <code>$WINEPREFIX</code> is really needed since we just need to grab a few files from the install:
</p>

<pre><code>$ wine setup_tes_morrowind_goty_2.0.0.7.exe /nogui</code></pre>

<p>
  The <code>/nogui</code> option that I'm passing to the installer makes it fall back to a basic windows installer GUI, versus the fancy GOG installer.
</p>

<h3>The OpenMW Runtime</h3>

<p>
  I'm dubbing the package I've put together the "OpenMW Runtime" becuase it includes OpenMW as well as five other libraries that it depends on.  If you aren't familiar with OpenMW, this might sound pretty crazy -- build five dependecies just to run it?!  Surely there are packages available, right?  Sort of.  In my case, on Void Linux, there were missing packages as well as "wrong" versions of packages:
</p>

<ul>
  <li>No MyGUI package.</li>
  <li>No Unshield package.</li>
  <li>The FFMPEG package is too new.</li>
  <li>The bullet package is too old (odd.. for a rolling release distribution..)</li>
  <li>The provided OSG package is linked against Qt5; OpenMW uses Qt4.</li>
</ul>

<p>
  Furthermore, the OpenMW project provides <a href="https://github.com/OpenMW/osg">their own fork of OSG</a> that is optimized specifically for the game -- we definitely want this!
</p>

<p>
  If you aren't using Void, the situation isn't much better:
</p>

<ul>
  <li>Only Debian's "unstable" repos carry OpenMW, I've not tried but I expect attempting an install on Jessie (the current "stable" release) will cause many package updates that you probably don't want.</li>
  <li>If you want to compile on Debian you'll likely have a bad time unless you're using testing or unstable due to dependencies that are too old.</li>
  <li>There are PPAs available for Ubuntu, but it seems silly to trust a PPA author when it's possible to just do it myself.</li>
  <li>Arch Linux looks to keep an up-to-date version of OpenMW, but I can't get behind using Arch for several reasons that I won't describe here.  If you use Arch, this is probably a decent option for you and you can stop reading now.
</ul>

<p>
  In the past I've tried to fill in the gaps of missing packages on Void by making my own MyGUI and Unshield packages, or when I used Debian I'd make my own debs, but all of that isn't really necessary just to install and play a game.  This is where the "OpenMW Runtime" comes in;  why worry about where to get all the right parts to play when you can indeed put them all together yourself!
</p>

<h3>Recipe for Magick</h3>

<p>
  I've put together a shell script to do all the work (that's <a href="https://hristos.triantafillou.us/playing-morrowind-on-gnulinux/">here</a>) - the only bit that is distro-specific is the part where packages get installed.  Below I'll go through each function one at a time, describing what it does and why it is needed.  I use the prefix <code>/opt/morrowind/$library-$version</code> for each component of the runtime;  this allows for easy updating of one or more component without mixing everything all together.  Annoying issues with library paths that arise from doing it this way will be solved later.
</p>

<p>
  Somewhat of a side note: I usually do builds like this in a virtual machine using a netinstall or similar media; this ensures that I'm working as close to a "clean" and/or minimalist environment as possible.
</p>

<h4>Build dependencies</h4>

<p>
  This is the only part that varies from setup to setup, and right now I've only covered Debian Jessie and Void Linux (but adding support for more distributions should be as easy as finding out names of packages.)  On Debian:
</p>

<pre><code># apt install build-essential cmake git libboost-dev libboost-filesystem-dev libboost-program-options-dev libboost-system-dev libbz2-dev libfreetype6-dev libgl1-mesa-dev libopenal-dev libqt4-dev libsdl2-dev nasm zlib1g-dev</code></pre>

<p>
  On Void Linux:
</p>

<pre><code># xbps-install boost-devel cmake freetype-devel gcc git libopenal-devel libtxc_dxtn libXt-devel make nasm ois-devel python-devel python3-devel qt-devel SDL2-devel zlib-devel</code></pre>

<p>
  This will provide everything that is needed to build the entire OpenMW runtime.
</p>

<h4>FFmpeg</h4>

<p>
  OpenMW depends on the older ffmpeg2 branch, which might be available on Debian and friends but definitely not in Void (which of course has the latest and greatest version.)  Thankfully, compiling FFmpeg isn't too big of a deal:
</p>

<pre><code>$ git clone https://github.com/FFmpeg/FFmpeg.git
$ cd FFmpeg
$ git checkout n2.8.11  # The latest 2.x branch as of this writing
$ ./configure --prefix=/opt/morrowind/ffmpeg-2.8.11
$ make  # Use -j$cpu_count at your option
$ sudo make install</code></pre>

<p>
  To elaborate:
</p>

<ol>
  <li>Clone down the source code.</li>
  <li>Check out the specific release that is needed.</li>
  <li>And the last three steps build and install the code to our specified prefix.</li>
</ol>

<p>
  This will take a minute or two to compile, but it should be relatively quick on a modern system.  One down, five to go!
</p>

<h4>OpenSceneGraph</h4>

<p>
  On Void Linux, the issue with the OSG package is that it is linked against Qt5 and OpenMW wants Qt4.  I would't expect this to be an issue on Debian and friends, but then that leaves the question about the OpenMW-specific OSG fork I mentioned earlier...  so I decided to include it in the OpenMW Runtime.  Problem solved!  Not much different from what we did for FFmpeg, except it is built with <a href="https://cmake.org/"><code>cmake</code></a>:
</p>

<pre><code>$ git clone https://github.com/OpenMW/osg.git osg-openmw
$ mkdir osg-openmw/build
$ cd osg-openmw/build
$ cmake -D CMAKE_INSTALL_PREFIX=/opt/morrowind/osg-openmw ..
$ make  # Again: use -j$cpu_count at your option
$ sudo make install</code></pre>

<p>
  Again, an explanation:
</p>

<ol>
  <li>Clone down the source code.</li>
  <li>Create and <code>cd</code> into a build directory (this is a <code>cmake</code>-ism.)</li>
  <li>This time a specific release is not used; instead the latest and greatest is what we want.</li>
  <li>The last three steps again build and install the code to our specified prefix, but this time using the <code>cmake</code>-specific ways of doing them..</li>
</ol>

<p>
  This one will take a bit to compile, even on a more powerful machine.  Two down - four more!
</p>

<h4>Bullet</h4>

<p>
  Oddly, as mentioned above, the <a href="http://bulletphysics.org/">Bullet</a> package in Void Linux is a tad behind - too much so for OpenMW.  I haven't used Debian in a while but last time I did they too had too old of a package.  In it goes, to the OpenMW Runtime:
</p>

<pre><code>$ git clone https://github.com/bulletphysics/bullet3.git
$ mkdir bullet3/build
$ cd bullet3/build
$ git checkout 2.86.1  # The latest tagged release as of this writing
$ cmake -D CMAKE_INSTALL_PREFIX=/opt/morrowind/bullet3-2.86.1
        -D BUILD_CPU_DEMOS=false \
        -D BUILD_OPENGL3_DEMOS=false \
        -D BUILD_BULLET2_DEMOS=false \
        -D BUILD_UNIT_TESTS=false \
        ..
$ make  # Again: use -j$cpu_count at your option
$ sudo make install</code></pre>

<p>
  A rundown:
</p>

<ol>
  <li>Clone down the source code.</li>
  <li>Create and <code>cd</code> into a build directory.</li>
  <li>Check out the latest tagged release.</li>
  <li>Again the build steps, again done in <code>cmake</code>-style, but this time several extra options are passed in to prevent building extra stuff like tests and demos that we do not need or want.</li>
</ol>

<p>
  Bullet compiles pretty quickly, once it's complete that's three down and three to go!
</p>

<h4>Unshield</h4>

<p>
  Most distributions probably have a package for <a href="https://github.com/twogood/unshield">Unshield</a>, Void Linux does not.  At any rate, it is a very small program and a quick breeze to build:
</p>

<pre><code>$ git clone https://github.com/twogood/unshield.git
$ mkdir unshield/build
$ cd unshield/build
$ git checkout 1.4.2  # The latest tagged release as of this writing
$ cmake -D CMAKE_INSTALL_PREFIX=/opt/morrowind/unshield-1.4.2 ..
$ make  # Use -j$cpu_count at your option
$ sudo make install</code></pre>

<p>
  This should finish very quickly, four down -- two to go!
</p>

<h4>MyGUI</h4>

<p>
  The last dependency to build for the OpenMW Runtime is <a href="http://mygui.info/">MyGUI</a>:
</p>

<pre><code>$ git clone https://github.com/MyGUI/mygui.git
$ mkdir mygui/build
$ cd mygui/build
$ git checkout 3.2.2  # The latest tagged release as of this writing
$ cmake -D CMAKE_INSTALL_PREFIX=${install_prefix}/mygui-${mygui_version} \
        -D MYGUI_RENDERSYSTEM=1 \
        -D MYGUI_BUILD_DEMOS=OFF \
        -D MYGUI_BUILD_TOOLS=OFF \
        -D MYGUI_BUILD_PLUGINS=OFF \
        ..
$ make  # Use -j$cpu_count at your option
$ sudo make install</code></pre>

<p>
  This pattern should be familiar by now.  Like Bullet, extra arguments are passed to <code>cmake</code> to ensure extraneous things are not built or included (such as Ogre support.)  Once this is done, all that's left is OpenMW itself!
</p>

<h4>OpenMW</h4>

<p>
  And now, the moment you've been waiting for - it is time to build OpenMW against our runtime:
</p>

<pre><code>$ git clone https://github.com/OpenMW/openmw.git
$ mkdir openmw/build
$ cd openmw/build
$ export openmw_short_sha=$(git rev-parse --short HEAD)
$ export CMAKE_PREFIX_PATH=/opt/morrowind/ffmpeg-${ffmpeg_version}:/opt/morrowind/osg-openmw:/opt/morrowind/unshield-${unshield_version}:/opt/morrowind/mygui-${mygui_version}:/opt/morrowind/bullet3-${bullet3_version}
$ export LDFLAGS="-lz -lbz2"
$ cmake -D CMAKE_INSTALL_PREFIX=/opt/morrowind/openmw-${openmw_short_sha} ..
$ make  # Use -j$cpu_count at your option
$ sudo make install</code></pre>

<p>
  Again the familiar <code>cmake</code> pattern, but this time we have to tell it where to find the rest of our OpenMW Runtime libraries (the stuff we just built.)  That's where setting and exporting <code>CMAKE_PREFIX_PATH</code> comes in, as well as the <code>LDFLAGS</code>.
</p>

<h3>How to play it</h3>

<p>
  The last step before actually playing the game is to create a small shell script that serves as a wrapper, since <code>LD_LIBRARY_PATH</code> will need to be set in order to use any of it.  Here's what I put at <code>/opt/morrowind/run.sh</code>:
</p>

<pre><code>#!/bin/sh

export LD_LIBRARY_PATH=$(realpath $(dirname ${0}))/unshield-1.4.2/lib64:$(realpath $(dirname ${0})/osg-openmw/lib64):$(realpath $(dirname ${0})/mygui-3.2.2/lib):$(realpath $(dirname ${0}))/bullet3-3.2.2/lib:$(realpath $(dirname ${0})/ffmpeg-2.8.11/lib)

if [ "${1}" = "--launcher" ]; then
    $(realpath $(dirname ${0}))/openmw-$openmw_short_sha/bin/openmw-launcher
else
    $(realpath $(dirname ${0}))/openmw-$openmw_short_sha/bin/openmw
fi</code></pre>

<p>
  First set the <code>LD_LIBRARY_PATH</code> such that it can find the OpenMW Runtime, then check for a <code>--launcher</code> argument and run the launcher if it's there, otherwise just run the <code>openmw</code> binary.
</p>

<p>
  For your first run, you should run the launcher and go through the installation wizard.  There will be an option to find an existing install; all it really wants are the <code>Morrowind.esa</code>, <code>Morrowind.bsa</code>, and the related files for the two expansions.  Point the wizard to the <code>Morrowind.esa</code> from your earlier wine install, then you should be ready to play!
</p>

<h3>Using mods</h3>

<p>
  A big part of why I prefer to use OpenMW over "vanilla" Morrowind is how OpenMW allows you to specify multiple data sources.  What that means is that you never have to overwrite any of the "vanilla" game files; your modded files can live alongside them in separate directpries and are read into the game as you would expect.  Of course things like load order and whatnot still apply, but in general this system of multipe data directories makes using mods so much easier.
</p>

<p>
  One caveat of this is that you must edit your local <code>$HOME/.config/openmw/openmw.cfg</code> file in order to configure it;  it is already a decent-sized file, and it can grow quite large once you add a bunch of mods.  That isn't really a caveat, and this actually makes it easy to include your OpenMW configuration in your dotfiles repo.  Snap!
</p>

<h3>Conclusion</h3>

<p>
  Compiling six programs to play a video game sounds extreme, but it isn't when you consider the impact of what has been described above.  Using open systems and software, one can enjoy video games - even fancy ones.  For an industry that is as typically closed as games this is pretty rad.  Not only that, but you now have a way to enjoy a supremely awesome classic RPG on (hopefully) any GNU/Linux distribution.
</p>

<p>
  All of the above comes out of a script I use for doing all of this automatically - you can find that <a href="https://github.com/hristoast/build-openmw">here</a> if you're so inclined to check it out.  Perhaps in a future entry I will go into further detail about mods and all that jazz.  Until then: wealth beyond measure, Outlander!
      </p>