• Vote in November Mapping Competition to select a winner!
  • There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

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

Fox Rother

Highly Skilled in Noobing
Joined
Aug 10, 2010
Messages
64
Reaction score
34
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
Joined
Aug 10, 2010
Messages
64
Reaction score
34
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
Joined
Aug 10, 2010
Messages
64
Reaction score
34
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
Joined
Aug 10, 2010
Messages
64
Reaction score
34
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
Joined
Aug 10, 2010
Messages
64
Reaction score
34
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:

Qexe

New Member
Joined
Oct 31, 2019
Messages
1
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?
 

Infernum

Senator
Joined
Feb 14, 2015
Messages
5,593
Solutions
555
Reaction score
3,518
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.
 

Nihilismo

New Member
Joined
May 9, 2008
Messages
58
Reaction score
0
Hello,
I'm having a problem with visual studio it says that it can't find a connection to the machine and i have to set it up at connection admin. But i can't seem to get the right configuration for the connection. Is there a missing section to this?
Here is the error im getting it's in spanish though
Code:
No se encuentra una conexión almacenada para la máquina "". Agregue una conexión nueva mediante Herramientas > Opciones > Multiplataforma > Administrador de conexiones.
 

fish04k

Member
Joined
Mar 23, 2008
Messages
101
Reaction score
16
Hello,
I'm having a problem with visual studio it says that it can't find a connection to the machine and i have to set it up at connection admin. But i can't seem to get the right configuration for the connection. Is there a missing section to this?
Here is the error im getting it's in spanish though
Code:
No se encuentra una conexión almacenada para la máquina "". Agregue una conexión nueva mediante Herramientas > Opciones > Multiplataforma > Administrador de conexiones.

I as well am having a similar issue. Ctrl+S CMake never works. Not sure how its suppose to have a connection with Ubuntu?
 

Fuzzy

New Member
Joined
Apr 18, 2019
Messages
8
Reaction score
0
Code:
1>------ Build started: Project: theforgottenserver, Configuration: Release x64 ------
1>otpch.cpp
1>c:\users\fuzzy\vcpkg\otservbr-global\src\otpch.h(45): fatal error C1083: Cannot open include file: 'boost/asio.hpp': No such file or directory
1>Done building project "theforgottenserver.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

file otpch.cpp
Code:
/**
 * @file otpch.cpp
 * 
 * The Forgotten Server - a free and open-source MMORPG server emulator
 * Copyright (C) 2019 Mark Samman <[email protected]>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include "otpch.h"
 
Last edited:

MV564

New Member
Joined
Feb 11, 2020
Messages
2
Reaction score
0
Hello.

I want to start an OT server for a part time project. I have some basic programming skills in Python and want to learn C++ to modify the OT more in depth.

I have some questions for you regarding your post.

-Can I use this configuration to test my server on Windows and then update the files on an Ubuntu server?
-Can I run this on a Windows server?
-What's the difference between development and production?

Thanks in advance!
MV
 

jonasu

Member
Joined
Nov 3, 2009
Messages
91
Solutions
1
Reaction score
11
Location
Stockholm, Sweden
For anyone with similar problems. "boost/asio cant be found"
I also needed to run below in my ubuntu WSL, before that it did not work and "tfs" starting file did not come up. The Cmake Configuration that was available in Visual Studio wass WSL-GCC-Debug
sudo apt-get install g++ gdb make ninja-build rsync zip
 
Top