As of version 3.7, Torque 3D supports being run under Linux using OpenGL for rendering. There are two broad approaches. You can build using the console only, or use an IDE with a GUI. The IDE we recommend for Ubuntu Linux is Qt Creator - however since the engine is configured using CMake, you can use any IDE that CMake can generate files for.
New to Torque? Be sure to read this guide to creating your first project.
Table of Contents
Using a virtual machine
If you don't have access to a Linux machine, or you prefer not to install libraries and software in your current Linux machine, building Torque inside a virtual machine is a great way to create binaries that you can redistribute. You can create your own virtual machine environment by following the steps on this page for Linux as usual, or you can use Vagrant to create reproducible VMs that you manage with the command-line. See the Vagrant tutorial for more details.
Prepare Linux for Torque
Prior to compiling Torque 3D under Linux, you will need to make sure you have the appropriate libraries and tools installed. The exact packages will depend on which Linux distribution you are using.
Hint: I couldn't compile on Ubuntu 16.10, but Ubuntu 16.04 worked well and I also had to install the package libgtk-3-dev .
These instructions may also work for other distributions using the RPM package manager. Let us know if you have trouble building on other distros!
In OpenSUSE 13.2, you will need to perform a couple of additional steps as described in this issue to compile the engine.
The file dialogs require GTK3 as well, so you will need to get the package for that if you do not already have it. The recommended command is this:
sudo apt-get install build-essential libgtk-3-dev
Compiling with CMake
You can either use the CMake GUI to generate a new project, or use CMake from the command-line. If you want to use the GUI, see the Windows guide for detailed instructions. Otherwise, continue on with the instructions below.
Do note: Many distros have out of date builds of cmake if you get them through the main update. Torque 3D requires at least version 3.1.4 to compile. If your versions is older than that, even after updating, you can go to cmake's website and either get a precompiled binary to use, or the code if you wish to compile it yourself, here.
First, make the directory the build files will live in:
mkdir -p My\ Projects/LinuxTest/buildFiles/ubuntu cd My\ Projects/LinuxTest/buildFiles/ubuntu
These directories start empty, but will be filled with template content soon. Now we can run CMake to configure the build we're going to make. The CMake command-line options let you enable various modules and options. We don't need any of them, fortunately, so we'll just specify the app name and build type:
cmake ../../../.. -DTORQUE_APP_NAME=LinuxTest -DCMAKE_BUILD_TYPE=Release
Take care to specify the same app name as the directory you created in the previous step, or your game will be placed in a different directory! CMake will detect the available compiler and other properties, and generate a Makefile in the current directory. If you'd prefer to use Ninja or one of CMake's other supported targets, you can use, for example,
cmake ../../../.. -G Ninja ...
The final output should look something like this:
-- Generating done -- Build files have been written to: /torque/My Projects/LinuxTest/buildFiles/ubuntu
Don't worry about errors related to CMP0004 - they're caused by changes in behaviour with new versions of CMake and the SDL library, and are harmless. We're finally ready to build!
Build from the command-line
Still in the same folder, run either make, ninja, or your build tool of preference.
The build may take some time, so go and frolic in the outdoors or something while you wait. When you return, you should see that the final executable was linked, and is now awaiting you in My\ Projects/LinuxTest/game.
Copy template files
You can run make install to copy the template files from the template you specified into your project's folder.
Build Using Code::Blocks (with cmakeGui)
Build using Qt Creator
We need to configure qtCreator.
- Open editor
- MenuBar -> Tools -> Options
- Build & Run -> CMAKE
- Click on Prefered Ninja Generator
- Close Options.
- MenuBar -> File -> Open File or Project
- Go to Torque3D root path
- Select CMakeList.txt
- We need to configure project. Select your path for CMAKE cache.
- Click Configure Project
- After this we get the normal CMAKE error message
-- Configuring incomplete, errors occurred! CMake Error at CMakeLists.txt:6 (message): Please set TORQUE_APP_NAME first
- We need to start CMAKE GUI for configure
- When finished , click Configuration button
- Return to qtCreator
- MenuBar -> Build -> Run CMake
- After this we have qtCreator configured for build
- If you have some problem, it's very important delete CMakeLists.txt.user file on Torque3D root path.
- You need to use INSTALL project for copy Template files
- Go to Project view
- On Build Steps, Make: Ninja -> click Details
- You see a list of projects you can add to build
- Add INSTALL project
- Return to Edit view
- MenuBar-> Build -> Build All
- After first build, is possible you prefer deactivate Install project for avoid override you files.
Note: it has been reported that in Fedora, you may need to change the default 'Make: ninja' command to ninja-build for both 'Build Steps' and 'Clean Steps'.
Compiling Dedicated/Server with the Project Generator
Torque 3D has a custom makefile generator known as the Project Manager, which is used to generate makefiles in Unix (or Visual Studio solutions in Windows). However, in Linux, the PG can only generate makefiles to build a dedicated server, not a full game client. Nevertheless, if you'd like to do that, simply:
- Change to you project's buildFiles/Make_Ded directory.
- Enter the make clean command.
- Enter the either the make debug or make release command depending on the type of build you wish to make.
- Go to your project's game/ directory.
- To start your game enter the following command (we'll use the name MyGame as the example project name):
./MyGame -dedicated -mission "levels/Empty Terrain.mis"
where the argument after the -mission switch is the path to the mission to load.