[Guide] Compiling & Running TFS 1.3 for Linux on Windows 10

Fox Rother

Highly Skilled in Noobing
Premium User
Joined
Aug 10, 2010
Messages
64
Best answers
0
Reaction score
31
About

You can follow this guide.

What is the goal of this guide:
A stable Windows development environment.

What is not the goal of this guide:
A production environment for TFS. Do not use it as a production set-up.

What this guide will teach you:
How to set up a Windows environment to compile TFS sources for Linux (on Windows) and run it without virtual machines.
After this guide, you'll be able to get the TFS source, edit it, compile it and run it.

What this guide will not teach you:
How to compile TFS for Windows. No .exe files!
You will be able to run your test server only within Ubuntu Windows Subsystem for Linux.

What you will use:
What you will not use:
  • Virtual Machines (VirtualBox, Vmware Player/Workstation, Vagrant).
  • Containerization and orchestration technologies (Docker, Kubernetes).

What this setup looks like:
1570924413762.png

Why this might be useful to you:
  • Very little overhead compared to using a VM.
  • Amazing development experience from Visual Studio.
  • Solid Linux compiling & execution environment.
  • Not "workaround" based. All the solutions respect the project design.
  • Very likely to work as advertised.
  • Source files stay in one place. No back and forth between systems.
  • You'll be better prepared to deploy your custom server to an actual server.

You need Windows 10 for this.
If it sounds good to you, then let's get to work! :D
 
Last edited:
OP
Fox Rother

Fox Rother

Highly Skilled in Noobing
Premium User
Joined
Aug 10, 2010
Messages
64
Best answers
0
Reaction score
31
Install

Ubuntu WSL

Enabling this feature on your machine
  • Search for "features" on your Start Menu.
  • Click on "Turn Windows features on and off". It'll look something llike this:
1570675646242.png

  • Next, check "Windows Subsystem for Linux":
1570675933649.png

  • Click OK.

Downloading, Installing & Setting-up
  • Click here to get to its page on the Windows Store (it's free, don't worry). Download it & Install it.
  • Click on the new "Ubuntu 18.04 LTS" tile that appeared on your Start Menu.
    I recommend you pin it on your Start Menu as well.
  • It'll continue its installation for a while and will then ask for a username and a password.
    Make them easy to remember. I just use "ubuntu" for the username.
  • Once it's finished, type sudo apt update -y and hit Enter. This will update your repositories.
    It'll ask for your password, just type it in (you won't see it) and press Enter. It might take a while.
  • Paste the following into your terminal and then hit Enter
    sudo apt install -y g++ make cmake build-essential gdb gdbserver rsync zip git libluajit-5.1-dev libgmp3-dev libmysqlclient-dev libboost-system-dev libboost-iostreams-dev libboost-filesystem-dev libpugixml-dev libcrypto++-dev mysql-server
    This will install compiling tools, Visual Studio requirements, development dependencies and MySQL for TFS.
    It might ask your password.

Visual Studio Community

Downloading, Installing & Setting-up
1570839736662.png

  • Click on "Install".
Cmder

Downloading, Installing & Setting-up
  • Click here to download the full version.
  • Extract it into a folder in your Home directory ("C:/Users/<Your user>") or "C:/".
    Might take a while to extract. I suggest that you also search for it on your Start Menu and pin it as a tile.
 
Last edited:
OP
Fox Rother

Fox Rother

Highly Skilled in Noobing
Premium User
Joined
Aug 10, 2010
Messages
64
Best answers
0
Reaction score
31
Build

Fetching TFS sources
  • Open Cmder and navigate to your user directory with the following command: cd C:/Users/<YourUser>
    Make sure<YourUser> is switched for... your Windows username. 🙃 You can type and enter "whoami" to see it.
  • Create a projects folder with mkdir projects and enter it with cd projects.
  • Fetch TFS sources with git clone https://github.com/otland/forgottenserver.git.

Setting up your Visual Studio Workspace & Compiling
  • Wtih Visual Studio, open the TFS source folder we just fetched.
  • Open "CMakeLists.txt" on the Solution Explorer, the panel on the right of your screen.
  • On the dropdown to the left of the build button (a green play button), select "Manage Configurations..."

1570846768738.png

  • Click on the red X button do delete the current configuration.
  • Click on the green + button to add a new configuration and select "WSL-Debug".
  • Very impotant: Hit CTRL + S!
  • Expand the "src" folder on the Solution Explorer.
  • Open the files "luascript.h" and "configmanager.cpp" and switch #include <lua.hpp> for #include <luajit-2.1/lua.hpp>.
    This change is not necessary to compile the sources. Its purpose is to tell IntelliSense which headers are being used on that file.
  • Open any file and try to compile. It'll probably fail.
  • Now select "tfs" on the drop down of the compile button and try again.
1570848454582.png


With that you should be able to compile everything! 🥳

It will not immediately run, though. Say what? 🤨

That's because TFS has a few execution dependencies.
So let's get this darling running in the next section! 🙃
 
Last edited:
OP
Fox Rother

Fox Rother

Highly Skilled in Noobing
Premium User
Joined
Aug 10, 2010
Messages
64
Best answers
0
Reaction score
31
Run

MySQL

Security set up
  • Open your Ubuntu WSL and check if MySQL server is running with sudo service mysql status.
  • If it's not running, start it with sudo service mysql start.
  • Secure your installation and set a password with sudo mysql_secure_installation.
    You'll be asked if a password strength checker should be installed. It's your call (I don't use it, since our environment is just for development).
  • The first thing you'll be asked is to set a password for the root user of your MySQL server.
    We now have a Linux root user and a MySQL root user. Don't mix them up!
  • Answer "y" to every question after setting a password.
1570922047147.png

Database & User creation
  • Create a database for TFS with sudo mysql -u root -p -e "CREATE DATABASE tfs;". Your MySQL root password will be asked.
    Might ask for your Ubuntu user password ("[sudo] password for <UbuntuUser>:" ) and then your MySQL root password ("Enter password:").
  • Import the TFS schema into our database with sudo mysql -u root -p tfs < /mnt/c/users/<YourUsername>/projects/forgottenserver/schema.sql where "<YourUsername>" is your Windows username. Your MySQL password will be asked again.
  • Create a user for TFS to use with sudo mysql -u root -p -e "CREATE USER 'tfsUser'@'localhost' IDENTIFIED BY '<Password>';". "<Password>" should be switched for something you'll remember.
  • Grant the tfsUser access to the tfs database with sudo mysql -u root -p -e "GRANT ALL PRIVILEGES ON tfs . * TO 'tfsUser'@'localhost';".

The Forgotten Server

Copying necessary files and folders
  • TFS needs two files and one folder to run. Open Cmder and move to TFS project folder with cd c:/users/<WindowsUser>/projects/forgottenserver.
  • Now run the following command to copy TFS dependencies to the build folder cp -r ./{config.lua.dist,key.pem,data} .\out\build\WSL-Debug\.
    You might have to convert key.pem's CRLF to LF, otherwise it'll cause "ERROR: Missing RSA private key footer". There are many solutions.
Configuring the server.
  • Open the "config.lua.dist" file (with any text editor of your choice) and "Save it as..." to another file called "config.lua".
  • Inside that new "config.lua", look for the MySQL section and change the parameters accordingly.
  • Save the file!


That's it. You can go to Visual Studio and start debugging! :)
 
Last edited:
OP
Fox Rother

Fox Rother

Highly Skilled in Noobing
Premium User
Joined
Aug 10, 2010
Messages
64
Best answers
0
Reaction score
31
Excel

I was originally intending to also give instructions on how to connect to this server, but that might be too obvious by now.
Additionally, I'm sure there are tutorials available right here for that! :p

You just started a delightful journey on understanding and extending what I think to be the most interesting open-source MMO project ever.
It has a very long history and affected thousands (if not millions) of people worldwide.

Awesome features by the community

Resources for learning C++
Microsoft's Reference
Deitels' C++ How to program
Erle Robotics' gitbook
Nicolai Josuttis' The C++ Standard Library - A Tutorial and Reference
Boris Schäling's The Boost C++ Libraries

Special thanks:
To @Delusion for giving me feedback and helping me out immensely with my first steps.
To @Znote for the very succint, yet highly useful overview on TFS architecture.
 
Last edited:
OP
Fox Rother

Fox Rother

Highly Skilled in Noobing
Premium User
Joined
Aug 10, 2010
Messages
64
Best answers
0
Reaction score
31
Need some input. Thanks.
 

Qexe

New Member
Joined
Oct 31, 2019
Messages
1
Best answers
0
Reaction score
0
Excel

I was originally intending to also give instructions on how to connect to this server, but that might be too obvious by now.
Additionally, I'm sure there are tutorials available right here for that! :p

You just started a delightful journey on understanding and extending what I think to be the most interesting open-source MMO project ever.
It has a very long history and affected thousands (if not millions) of people worldwide.

Awesome features by the community

Resources for learning C++
Microsoft's Reference
Deitels' C++ How to program
Erle Robotics' gitbook
Nicolai Josuttis' The C++ Standard Library - A Tutorial and Reference
Boris Schäling's The Boost C++ Libraries

Special thanks:
To @Delusion for giving me feedback and helping me out immensely with my first steps.
To @Znote for the very succint, yet highly useful overview on TFS architecture.
Thank you! Do you know if this works with TFS 1.2 as well?
 
OP
Fox Rother

Fox Rother

Highly Skilled in Noobing
Premium User
Joined
Aug 10, 2010
Messages
64
Best answers
0
Reaction score
31
Thank you! Do you know if this works with TFS 1.2 as well?
Might have some tweaks of its own, but should work normally. :b
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,230
Best answers
511
Reaction score
2,857
Thank you! Do you know if this works with TFS 1.2 as well?
All you really need is to just open up a WSL container and follow the compilation instructions on github and it works.
 
Top