Compiling MTASA: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (add img)
No edit summary
Line 1: Line 1:
__NOTOC__
In order to successfully build Multi Theft Auto from source, it is necessary to perform a number of steps, which we will explain below.
In order to successfully build Multi Theft Auto from source, it is necessary to perform a number of steps, which we will explain below.  You should be using Windows 7 or above to build.


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


Before you can build Multi Theft Auto, make sure you have the following software and SDKs installed:
== Prerequisites ==
* Visual Studio '''2015'''
** '''Recommended:''' [https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx Microsoft Visual Studio 2015] (Community Edition is free).
** '''missing #include "afxres.h"''': [[Media:Vs2015_foundationClasses.png|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)
* [http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=6812 Microsoft DirectX SDK]
** '''S1023 Error:''' [https://support.microsoft.com/en-us/kb/2728613 "S1023" error when you install the DirectX SDK (June 2010)]


If you haven't already done so, install a client such as [https://www.sourcetreeapp.com/ SourceTree] or [https://windows.github.com/ GitHub for Windows], which can be used to download and manage the code.
You should be using Windows 7 or above, before you can compile the Multi Theft Auto client.


=== Getting the latest source code ===
Make sure you have the following software and SDKs installed:


To get the latest code, you will have to download the latest copy of our Git repository - you can get it [https://github.com/multitheftauto/mtasa-blue here] ([https://github.com/multitheftauto/mtasa-blue/archive/master.zip zip]|[https://github.com/multitheftauto/mtasa-blue/archive/master.tar.gz tar.gz])
=== Visual Studio 2015 ===
[[File:Visual_Studio_Community.PNG|left|150px|link=https://beta.visualstudio.com/downloads/]]
'''Download'''<br>
[https://beta.visualstudio.com/downloads/ Microsoft Visual Studio 2015] (Community Edition is free).<br>


=== Before building the software ===
'''Addon: EditorConfig''' (optional)<br>
Download: [https://visualstudiogallery.msdn.microsoft.com/c8bccfe2-650c-4b42-bc5c-845e21f96328 EditorConfig]<br>
(Install this addon to automatically set up your IDE for the correct code formatting)


To ensure the target directories have the correct permissions it is '''vital''' to install [http://nightly.mtasa.com/?mtasa-{{Current Version|master}}-full_unstable-latest the latest unstable nightly Windows full installer] into this '''exact''' directory:
'''Missing #include "afxres.h"'''<br>
    C:\Program Files\MTA San Andreas {{Current Version|master}}\
[[Media:Vs2015_foundationClasses.png|Make sure you have ''Microsoft Foundation Classes for C++'' installed.]]<br>
If you have 64 bit windows, be sure to remove (x86) from the path.
(You can re-run the installer to modify your current installation, no need to uninstall and reinstall)<br style="clear:both">
 
=== Microsoft DirectX SDK ===
[[File:DirectX_SDK.jpg|left|150px|link=https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=6812]]
'''Download'''<br>
[http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=6812 Microsoft DirectX SDK]<br>
 
'''S1023 Error'''<br>
[https://support.microsoft.com/en-us/kb/2728613 "S1023" error when you install the DirectX SDK (June 2010)]<br style="clear:both">
 
=== Git Client ===
You have 2 options here available. You can install '''ONE''' of the clients below (for collaboration) or download the entire codebase in a [https://github.com/multitheftauto/mtasa-blue/archive/master.zip .ZIP] file (if you only want to compile the code).
 
==== GitHub Desktop ====
[[File:GitHub_Desktop.png|left|150px]]
'''Download:'''<br>
[https://windows.github.com/ GitHub for Windows]<br style="clear:both">
 
==== SourceTree ====
[[File:Atlassian_SourceTree.png|left|150px]]
'''Download:'''<br>
[https://www.sourcetreeapp.com/ SourceTree]<br style="clear:both">
 
== Getting the latest source code ==
 
To get the latest code, you will have to download the latest copy of our Git repository.<br>
We recommend cloning the repository in your Git client, because you can pull any updates from there easily.


=== Building the software ===
* '''Repository:''' [https://github.com/multitheftauto/mtasa-blue multitheftauto/mtasa-blue]
* '''.zip:''' [https://github.com/multitheftauto/mtasa-blue/archive/master.zip master.zip]
* '''.tar.gz:''' [https://github.com/multitheftauto/mtasa-blue/archive/master.tar.gz master.tar.gz]


In order to build the source, you will need Microsoft Visual Studio. Open the project file in '''Shared/Core 2013.sln''' and build using one of the project configurations ''Debug'' or ''Release''. Note that everything will run significantly slower in ''Debug'' mode.
== Getting the latest network module ==


=== Target directory and permissions ===
You should install [http://nightly.mtasa.com/?mtasa-{{Current Version|master}}-full_unstable-latest the latest unstable nightly Windows full installer] into this '''exact''' directory:
    C:\Program Files\MTA San Andreas {{Current Version|master}}\
If you have 64 bit windows, be sure to remove (x86) from the path.


By default, the current version compiles the binaries into '''C:\Program Files\MTA San Andreas {{Current Version|master}}\'''. To ensure the correct permissions, registry entries and support files are present, you should install [http://nightly.mtasa.com/?mtasa-{{Current Version|master}}-full_unstable-latest the latest unstable nightly Windows full installer] into that directory. Also make sure to add write permissions for your user to that directory.
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 [http://nightly.mtasa.com/?mtasa-{{Current Version|master}}-full_unstable-latest latest nightly].<br>
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.


=== Getting the latest network module ===
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.


Since the '''netc.dll'''/'''net.dll''' network modules for the client 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, MTA expects a debug version of the net dll. As we don't provide this, you can append '_d' to the filename of a release dll.
== Compilling the code ==
# Execute the script '''create-projects.bat'''
# Open the solution file '''MTASA.sln''' in the '''Build''' directory
# Compile in Visual Studio (may take some minutes)
## Compile in '''Debug''' config
## Compile in '''Nightly''' config (you will be missing the essential ''libcef.dll'' if you don't do this step)
# Install data files: '''utils\premake5.exe install_data''' (''Shift + Right-Click'' in the ''<root>'' directory and click on [http://michaelcrump.net/files/image_635243330608233338.png ''Open command window here''])
# Install resources: '''utils\premake5.exe install_resources''' (optional step)


Furthermore, it is advisable to create an empty "timeout.longtime" file in your MTA 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.
=== 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 =


You are almost ready to run your build of the Multi Theft Auto software.
== Running the client ==


=== Running the game 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.<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.


Double check you have installed [http://nightly.mtasa.com/?mtasa-{{Current Version|master}}-full_unstable-latest the latest unstable nightly Windows full installer].
== Running the dedicated server ==


=== Running the dedicated server ===
If you already have run the step 5 (''Install resources'') in ''Compilling 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.
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: [https://github.com/multitheftauto/mtasa-resources]. It's recommended that you check out the latest resources from there or [http://mirror.mtasa.com/mtasa/resources/ download a zipped revision from here]. Make sure that you are not using any of our resources from any previous versions of Multi Theft Auto, as this '''will''' cause issues.
Our official resources repository is hosted on GitHub: [https://github.com/multitheftauto/mtasa-resources]. You can checkout the latest resources from there or [http://mirror.mtasa.com/mtasa/resources/ download a zipped revision from here]. Make sure that you are not using any of our resources from any previous versions of Multi Theft Auto, as this '''will''' cause issues.


If you have any problems with missing DLL files (e.g. libcurl.dll), then you didn't install the Windows full installer properly.
=== 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.<br>
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.


= Getting involved =
= Getting involved =
Line 57: Line 106:


= Additional information =
= Additional information =
 
If you need more information, try our [http://bugs.mtasa.com/ bug tracker] or [irc://irc.multitheftauto.com IRC channel].
If you need more information, try our [http://bugs.mtasa.com/ bug tracker], [irc://irc.multitheftauto.com IRC channel].


[[pt-br:Compilando o MTASA]]
[[pt-br:Compilando o MTASA]]
[[ru:Compiling MTASA]]
[[ru:Compiling MTASA]]
[[Category: Development]]
[[Category: Development]]

Revision as of 16:54, 4 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

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).

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. 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.

Compilling 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 (may take some minutes)
    1. Compile in Debug config
    2. Compile in Nightly config (you will be missing the essential libcef.dll if you don't do this step)
  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)

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).

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.

Running the dedicated server

If you already have run the step 5 (Install resources) in Compilling 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: [1]. You can checkout the latest resources from there or download a zipped revision from here. Make sure that you are not using any of our resources from any previous versions of Multi Theft Auto, as this will cause issues.

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.

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.