Setting up a Windows compile environment using WSL

This guide describes the steps that are needed to be able to compile NML NewGRFs on a 64 bit Windows 10 system with the Anniversary update, using the make system as used by the #openttdcoop DevZone. This guide uses the Windows Subsystem for Linux (WSL). If you have a version of Windows that does not have WSL (32 bits or Windows versions before W10 Anniversary update), use the Complete Guide for Windows users.

Installing programs

The following programs will be installed on your computer during this guide:
  • WSL
  • make*
  • TortoiseHg*
  • GCC*
  • Additional Python files*
  • ply*
  • NML*

The with a * marked programs will be installed inside the WSL environment.

Installing WSL

WSL is an optional feature included with Windows from Windows 10 Anniversary update. It can be installed using the Control Panel/Programs and Features/Turn Windows features on or off.

Select the Windows Subsystem for Linux (Beta) and press OK. The computer will now ask to reboot, do not restart yet.

Go to PC Settings/Update & security and select the For developers options. Set your computer to Developer mode, read and confirm the warning. If your computer is not set to Developer mode WSL cannot be installed.

Now restart your computer.

Open a command prompt and run bash. Follow the steps given by the installation program. After the installation program is finished, you will be in the bash prompt, or you can restart it by running bash (either from the command prompt, the start menu or the Run window).

Installing make, TortoiseHg and gcc and additional Python files

With the bash window open, it is time to install the programs needed to make NewGRFs. These programs are installed using the following command: sudo apt-get install <program>

So to install the listed programs, simply execute the following commands and provide your password or confirm the actions if asked:
sudo apt-get install make
sudo apt-get install tortoisehg
sudo apt-get install gcc
sudo apt-get install python3-pil

For the following steps, also install the Python setup tools using the following command:
sudo apt-get install python3-setuptools

Installing ply

Installing ply and NML require different steps, as those cannot be installed using apt-get. Download ply from the ply website . Open the file with a program like 7-Zip, and keep opening the single folder until you get the following result:

Create a Temp folder on your C:\ drive and add a folder for Ply to it. Copy the entire contents of the download to this folder.

In bash, use cd to get to the folder. If you copied the contents to C:\Temp\ply, you can reach the folder by cd /mnt/c/Temp/ply.

Install ply using the command sudo python3.4 setup.py install.

Installing NML

NML can be downloaded from the #openttdcoop bundles-sever . You can choose between Releases and Push. Releases are marked as stable and also contain older versions if needed, while Push contains the latest changes. For this guide it does not matter which one you use, the steps are the same for all versions.

Download the file named nml-<version>.tar.gz, where <version> is the version number of NML you are downloading. The other files are not relevant.

Open the file with a program like 7-Zip, and keep opening the single folders until you get the following result:

In the earlier created Temp folder add a folder for NMLto it. Copy the entire contents of the download to this folder.

In bash, use cd to get to the folder. If you copied the contents to C:\Temp\NML, you can reach the folder by cd /mnt/c/Temp/ply.

Install NML using the command sudo python3.4 setup.py install.

Compiling your NewGRF

If all is working up to now, open bash and change the directory using the cd command to the folder containing your code. You can then use the make command to start the compiling of your NewGRF.

If you do not want to use cd to the right directory every time, you can also use shift+right click and open a command window from the context menu, and running bash from here will put it in the same directory.

Common errors

ply or NML installation fails with ImportError

Installation of ply and NML can fail with the following message:
ImportError: No module names 'setuptools'

This means the setuptools have not been installed. These can be installed using sudo apt-get install python3-setuptools

TortoiseHg does not trust hgrc

It can happen that TortoiseHg does not trust the hgrc file in your repository, giving the following error:
not trusting file /mnt/<Path to repo>/.hg/hgrc from untrusted user root, group root

This can be solved by adding the root group to the trusted groups. Stop the make process using Ctrl+C. Go to the home directory using cd $Home. From the home directory, run nano .hgrc. This will open a text editor. Add the following text to it and save:
[trusted]
groups = root

Bash.PNG (7.57 KB) Transportman, 2016-08-08 15:32

Features.PNG (44.7 KB) Transportman, 2016-08-08 15:32

Installing programs.PNG (40.5 KB) Transportman, 2016-08-08 15:32

NML download.PNG (59 KB) Transportman, 2016-08-08 15:32

NML install error.PNG (11.5 KB) Transportman, 2016-08-08 15:32

NML unzip.PNG (35.3 KB) Transportman, 2016-08-08 15:32

Ply.PNG (41.5 KB) Transportman, 2016-08-08 15:32

PC Settings.PNG (40.4 KB) Transportman, 2016-08-08 15:32

Trust.PNG (13.5 KB) Transportman, 2016-08-08 15:32