Compiling MTASA: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Fixed missing libcurl.dll issue in commit/8e72d31f9ba37b9ba7894e01a388ff5a4508d818)
No edit summary
Line 62: Line 62:
If you want to run a debug version of MTA, the client expects a debug version of the net.dll. As we don't provide this, you can append '_d' to a copy of the network dll.
If you want to run a debug version of MTA, the client expects a debug version of the net.dll. As we don't provide this, you can append '_d' to a copy of the network dll.


Furthermore, it is advisable to create an empty "timeout.longtime" file in your ''Bin/server/'' directory. This will extend the time before players are kicked from your server for unresponsiveness to 120 seconds. This is useful when in Debug mode on the client and the process is halted.
Furthermore, it is advisable to create an empty "timeout.longtime" file in your ''Bin/server/'' directory, but you have to compile the code first.<br>
This will extend the time before players are kicked from your server for unresponsiveness to 120 seconds. This is useful when in Debug mode on the client and the process is halted.


== Compiling the code ==
== Compiling the code ==
Line 72: Line 73:
# Copy ''server/net.dll'' to '''Bin/server''' and ''MTA/netc.dll'' to '''Bin/mta''' directory respectively from ''C:\Program Files\MTA San Andreas {{Current Version|master}}\''
# Copy ''server/net.dll'' to '''Bin/server''' and ''MTA/netc.dll'' to '''Bin/mta''' directory respectively from ''C:\Program Files\MTA San Andreas {{Current Version|master}}\''
# Clone and rename both ''Bin/server/net.dll'' and ''Bin/mta/netc.dll' with the suffix '_d' (e.g. '''Bin/server/net_d.dll''')
# Clone and rename both ''Bin/server/net.dll'' and ''Bin/mta/netc.dll' with the suffix '_d' (e.g. '''Bin/server/net_d.dll''')
=== Microsoft DirectX SDK (August 2009) includes missing ===
You can either use the [https://www.microsoft.com/en-us/download/details.aspx?id=23549 DirectX SDK (August 2009)] package or modify the source code to omit this warning to compile the code anyway (might break shaders etc.):<br>
Open the file ''mtasa-blue\Client\core\DXHook\CDirect3DHook9.cpp'' in an editor of your choice and go to the line
  #if D3DX_SDK_VERSION != 42
and change it to
  #if D3DX_SDK_VERSION != 43
(for June 2010 SDK).


= Running the software =
= Running the software =
Line 86: Line 79:


You can start your client in the '''Bin''' directory. You might find there a ''Multi Theft Auto.exe'' and/or ''Multi Theft Auto_d.exe'' executable. The ''_d'' suffix indicates a debug build of the software.<br>
You can start your client in the '''Bin''' directory. You might find there a ''Multi Theft Auto.exe'' and/or ''Multi Theft Auto_d.exe'' executable. The ''_d'' suffix indicates a debug build of the software.<br>
Furthermore, you can also run your client inside the debugger from Visual Studio if you want to investigate a stack trace or set breakpoints in interesting code regions.
Furthermore, you can also run your client inside the debugger from Visual Studio if you want to investigate a stack trace or set breakpoints in interesting code regions (read more in the section below).


== Running the dedicated server ==
== Running the dedicated server ==
Line 96: Line 89:


Our official resources repository is [https://github.com/multitheftauto/mtasa-resources hosted on GitHub]. You can download the latest resources from there or [http://mirror.mtasa.com/mtasa/resources/ download a zipped version]. Make sure that you have the latest resources package.
Our official resources repository is [https://github.com/multitheftauto/mtasa-resources hosted on GitHub]. You can download the latest resources from there or [http://mirror.mtasa.com/mtasa/resources/ download a zipped version]. Make sure that you have the latest resources package.
=== Missing mtaserver.conf ===
If you are missing the default configuration files for your server then go ahead and install these from [https://linux.mtasa.com/dl/152/baseconfig-1.5.2.tar.gz here] and extract all three files to '''Bin/server/mods/deathmatch'''.


=== Starting the server ===
=== Starting the server ===
Line 105: Line 95:


If you have any problems with missing DLL files (e.g. libcurl.dll), then you can copy these from your MTA installation.
If you have any problems with missing DLL files (e.g. libcurl.dll), then you can copy these from your MTA installation.
== Debugging ==
If you already compiled the code in the '''Debug''' configuration then continue reading, if not, then go up to ''Compilling the code'' and follow the steps for a ''Debug'' build.<br>
You can either launch MTA yourself and attach any debugger you want to use (also applies to the Visual Studio debugger) or you start a local debugging session in Visual Studio.<br>
If you choose to run MTA with Visual Studio then you should also attach the debugger to the executable '''gta_sa.exe''' (press ''CTRL + ALT + P'' in Visual Studio) - otherwise your
breakpoints will not work for anything beside the MTA Launcher project.
[[File:Attach_to_Process.png|600px]]
== Troubleshooting ==
=== Microsoft DirectX SDK (August 2009) includes missing ===
You can either use the [https://www.microsoft.com/en-us/download/details.aspx?id=23549 DirectX SDK (August 2009)] package or modify the source code to omit this warning to compile the code anyway (might break shaders etc.):<br>
Open the file ''mtasa-blue\Client\core\DXHook\CDirect3DHook9.cpp'' in an editor of your choice and go to the line
  #if D3DX_SDK_VERSION != 42
and change it to
  #if D3DX_SDK_VERSION != 43
(for June 2010 SDK).
=== Missing mtaserver.conf ===
If you are missing the default configuration files for your server then go ahead and install these from [https://linux.mtasa.com/dl/152/baseconfig-1.5.2.tar.gz here] and extract all three files to '''Bin/server/mods/deathmatch'''.


= Getting involved =
= Getting involved =

Revision as of 17:07, 6 September 2016

In order to successfully build Multi Theft Auto from source, it is necessary to perform a number of steps, which we will explain below.

Please read the instructions carefully and do not skip parts of it, if you have no experience.

Prerequisites

You should be using Windows 7 or above, before you can compile the Multi Theft Auto client.

Make sure you have the following software and SDKs installed:

Visual Studio 2015

Visual Studio Community.PNG

Download
Microsoft Visual Studio 2015 (Community Edition is free).

Addon: EditorConfig (optional)
Download: EditorConfig
(Install this addon to automatically set up your IDE for the correct code formatting)

Missing #include "afxres.h"
Make sure you have Microsoft Foundation Classes for C++ installed.
(You can re-run the installer to modify your current installation, no need to uninstall and reinstall)

Microsoft DirectX SDK

DirectX SDK.jpg

Download
Microsoft DirectX SDK

S1023 Error
"S1023" error when you install the DirectX SDK (June 2010)

Git Client

Git logo.png

You have 2 options here available. You can install ONE of the clients below (for collaboration) or download the entire codebase in a .ZIP file (if you only want to compile the code). You can also use Git on the command line to checkout the respository.

GitHub Desktop

GitHub Desktop.png

Download:
GitHub for Windows

SourceTree

Atlassian SourceTree.png

Download:
SourceTree

Getting the latest source code

To get the latest code, you will have to download the latest copy of our Git repository.
We recommend cloning the repository in your Git client, because you can pull any updates from there easily.

Getting the latest network module

You should install the latest unstable nightly Windows full installer into this exact directory:

   C:\Program Files\MTA San Andreas 1.6\

If you have 64 bit windows, be sure to remove (x86) from the path.

Since the netc.dll/net.dll network modules for the software are covered by a different license, you will have to use the binary files that get installed with the latest nightly.
If you want to run a debug version of MTA, the client expects a debug version of the net.dll. As we don't provide this, you can append '_d' to a copy of the network dll.

Furthermore, it is advisable to create an empty "timeout.longtime" file in your Bin/server/ directory, but you have to compile the code first.
This will extend the time before players are kicked from your server for unresponsiveness to 120 seconds. This is useful when in Debug mode on the client and the process is halted.

Compiling the code

  1. Execute the script create-projects.bat
  2. Open the solution file MTASA.sln in the Build directory
  3. Compile in Visual Studio with Debug (may take some minutes)
  4. Install data files: utils\premake5.exe install_data (Shift + Right-Click in the <root> directory and click on Open command window here)
  5. Install resources: utils\premake5.exe install_resources (optional step)
  6. Copy server/net.dll to Bin/server and MTA/netc.dll to Bin/mta directory respectively from C:\Program Files\MTA San Andreas 1.6\
  7. Clone and rename both Bin/server/net.dll and Bin/mta/netc.dll' with the suffix '_d' (e.g. Bin/server/net_d.dll)

Running the software

Running the client

You can start your client in the Bin directory. You might find there a Multi Theft Auto.exe and/or Multi Theft Auto_d.exe executable. The _d suffix indicates a debug build of the software.
Furthermore, you can also run your client inside the debugger from Visual Studio if you want to investigate a stack trace or set breakpoints in interesting code regions (read more in the section below).

Running the dedicated server

If you already have run the step 5 (Install resources) in Compiling the code to install resources then you can goto Starting the server.

Installing the latest resources

If you want to run the Multi Theft Auto dedicated server, you will have to install the required resources. These are required because they implement the most basic functionality (e.g. spawning players) in order to play.

Our official resources repository is hosted on GitHub. You can download the latest resources from there or download a zipped version. Make sure that you have the latest resources package.

Starting the server

To run the server, open the MTA Server.exe executable in the Bin/server directory. The _d suffix indicates a debug build of the software.
You can also run the debug build MTA Server_d.exe in the Visual Studio Debugger.

If you have any problems with missing DLL files (e.g. libcurl.dll), then you can copy these from your MTA installation.

Debugging

If you already compiled the code in the Debug configuration then continue reading, if not, then go up to Compilling the code and follow the steps for a Debug build.
You can either launch MTA yourself and attach any debugger you want to use (also applies to the Visual Studio debugger) or you start a local debugging session in Visual Studio.
If you choose to run MTA with Visual Studio then you should also attach the debugger to the executable gta_sa.exe (press CTRL + ALT + P in Visual Studio) - otherwise your breakpoints will not work for anything beside the MTA Launcher project.

Attach to Process.png

Troubleshooting

Microsoft DirectX SDK (August 2009) includes missing

You can either use the DirectX SDK (August 2009) package or modify the source code to omit this warning to compile the code anyway (might break shaders etc.):
Open the file mtasa-blue\Client\core\DXHook\CDirect3DHook9.cpp in an editor of your choice and go to the line

 #if D3DX_SDK_VERSION != 42

and change it to

 #if D3DX_SDK_VERSION != 43

(for June 2010 SDK).

Missing mtaserver.conf

If you are missing the default configuration files for your server then go ahead and install these from here and extract all three files to Bin/server/mods/deathmatch.

Getting involved

Please see our Coding guidelines for information on coding practice.

Additional information

If you need more information, try our bug tracker or IRC channel.