Compiling MTASA: Difference between revisions
mNo edit summary |
Fernando187 (talk | contribs) m (mirror.mtasa => mirror.multitheftauto.com/mtasa/resources) |
||
(19 intermediate revisions by 10 users not shown) | |||
Line 9: | Line 9: | ||
Make sure you have the following software and SDKs installed: | Make sure you have the following software and SDKs installed: | ||
=== Visual Studio | === Visual Studio 2022 === | ||
[[File:Visual_Studio_Community.PNG|right|150px|link=https://www.visualstudio.com/vs/]] | [[File:Visual_Studio_Community.PNG|right|150px|link=https://www.visualstudio.com/vs/]] | ||
# '''[https://visualstudio.microsoft.com/vs/ Download Microsoft Visual Studio | # '''[https://visualstudio.microsoft.com/vs/ Download Microsoft Visual Studio 2022]''' - make sure you get the Community Edition, that one is free. | ||
# On the installation checklist, [[:File:VsFoundationClasses.png|make sure you tick these | # On the installation checklist, [[:File:VsFoundationClasses.png|make sure you tick these 2 items]]: | ||
## ''Desktop development with C++'' | ## ''Desktop development with C++'' | ||
## ''C++ MFC for latest | ## Optional component ''C++ MFC for latest v143 build tools (x86 & x64)'' | ||
If you don't enable MFC, you will get the following error: <code>cannot open include file 'afxres.h'</code>. | If you don't enable MFC, you will get the following error: <code>cannot open include file 'afxres.h'</code>. | ||
Line 24: | Line 24: | ||
'''Download Microsoft DirectX SDK (August 2009) (DXSDK_Aug09.exe):''' | '''Download Microsoft DirectX SDK (August 2009) (DXSDK_Aug09.exe):''' | ||
* [https://archive.org/download/dxsdk_aug09/DXSDK_Aug09.exe Mirror 1] | * [https://archive.org/download/dxsdk_aug09/DXSDK_Aug09.exe Mirror 1] | ||
* [https:// | * [https://mega.nz/file/pQJCiAJY#jBcYT6ZP4DMBpnm12BLRto9EQ-RjjpP3BWkSPanpvLI Mirror 2] | ||
{| class="wikitable" style="margin-top: 0px; width: 70%; word-break: break-all;" | |||
|+ File verification | |||
|- style="vertical-align:bottom;" | |||
! colspan="2" | Algorithm and variant | |||
! Hash | |||
|- style="text-align:center;vertical-align:center;" | |||
| rowspan="6" | '''{{nowrap|SHA-3}}''' || ''SHA3-224'' || 8bfcdc03518d7edd34689534fd4d21291469ff2f2eb10437ad648c58 | |||
|- style="text-align:center;vertical-align:center;" | |||
| ''SHA3-256'' || 45bf3e08da3b3636ddb4f4a74243430f8d65759c074c0d79756ef810c4701c5a | |||
|- style="text-align:center;vertical-align:center;" | |||
| ''SHA3-384'' || b358e529963d6f5fd7f8bd4b530fb18f6a2e6a442009a54e981b2f9967589ed48150af310f283640d56f9b60d41100c9 | |||
|- style="text-align:center;vertical-align:center;" | |||
| ''SHA3-512'' || 43522187053af744250059ef69c0f3083cecd1157fe56daac16b9497ebc6fb5b525875144e42898367c55f757cffd3526f37074d544470578602a5a944a45a75 | |||
|- style="text-align:center;vertical-align:center;" | |||
| ''SHAKE128'' || 2a7c81bde9e867cbb5ef00b72ad8de66a3ee64c1d59f16465fa712479b6a84d28a02cc5ed08afa1d51e72011657453dbd4656cc9340d32e18179c39d03982dfc35c8f0c2a5c99e11dc74d0e23ed21b1e55f19c809a5a152bde39a2d46fcd12421f373f2d691ade1b57faf6c2ab7aded5a7d174f1f1c77127c0d6a1523b4775c569c5e1b4efa2da4bf2f708a96707a709e245a7f507382e69a81777919c90e95a091c0b699ce7f517 | |||
|- style="text-align:center;vertical-align:center;" | |||
| ''SHAKE256'' || 9c100dac5245a61774f3a2752bf9e941bdcd5654b18035155161c63b20936dfc9bd7334feb9a6fe9a99a65491161083b39ac3bd578e2cf4f90cba3c786e9924fa0611f65a725331b77b63e7c8b552e1637bc77531ba0f2c9cac72115b28e523929ede4e5b246a0755e8d5c4089d94bf16627fb08672cfffa523bba3d976489a0eec60d3c6a96ca2b | |||
|- style="text-align:center;vertical-align:center;" | |||
| rowspan="6" | '''{{nowrap|SHA-2}}''' || ''SHA-224'' || a3a74b89cccfe314b79418d5598aac5e94800221e5d945c74f15c004 | |||
|- style="text-align:center;vertical-align:center;" | |||
| ''SHA-256'' || 4ab1de69312f10f6b41310a5218d80c478bbd823bc0f86627318d690b128fb9f | |||
|- style="text-align:center;vertical-align:center;" | |||
| ''SHA-384'' || 254ed29c6ad2cadc6f013d2d51c0ac78a6bbe236a2c94ca99610eba8b2c1200d1a62c445ca9ee51bb09354875d5eca8a | |||
|- style="text-align:center;vertical-align:center;" | |||
| ''SHA-512'' || style="width: 60%;" | 736393c0dfa32221e229890f87eb330174d70dd2a02fa0cace303816d3e7a10a332a44129748de39665d1b339e627d6028c2080268f7afdd5240c447fec8ff0b | |||
|- style="text-align:center;vertical-align:center;" | |||
| ''SHA-512/224'' || 7e23d9ba916000782a17e23abf48e25237f45590cfe767aed9d79f10 | |||
|- style="text-align:center;vertical-align:center;" | |||
| ''SHA-512/256'' || 0c833a56046fe7e4213fcb1862c730acf313d1b8f60b51eebf64dc3e79730c1c | |||
|- style="text-align:center;vertical-align:center;" | |||
| colspan="2" | '''MD5''' || 66e5379ecf46b014688779621bcc677c | |||
|- style="text-align:center;vertical-align:center;" | |||
| colspan="2" | '''{{nowrap|SHA-1}}''' || 5b9b969ed7b6cf5534bb7350e44c09b3573b0e71 | |||
|- style="text-align:center;vertical-align:center;" | |||
| colspan="2" | '''{{nowrap|CRC32}}''' || e9f5c61d | |||
|} | |||
'''NOTE:''' Restart your computer after installing ''Microsoft DirectX SDK'', because otherwise the environment variable '''DXSDK_DIR''' won't be available yet. After restarting it re-run '''create-projects.bat''' | '''NOTE:''' Restart your computer after installing ''Microsoft DirectX SDK'', because otherwise the environment variable '''DXSDK_DIR''' won't be available yet. After restarting it re-run '''create-projects.bat''' | ||
Line 44: | Line 76: | ||
'''S1023 Error'''<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"> | [https://support.microsoft.com/en-us/kb/2728613 "S1023" error when you install the DirectX SDK (June 2010)]<br style="clear:both"> | ||
'''Cannot open source file "xxx.h" after upgrading to Visual Studio 2022'''<br> | |||
If you've just upgraded to Visual Studio 2022 and were working on MTA using a previous version, you may receive errors about header files not being found (stdio.h, stddef.h, etc) when building the project. | |||
Make sure you have the latest Windows 10 SDK installed (via the Visual Studio Installer) and restart your PC. | |||
If that doesn't work - close Visual Studio, go into the `Build` folder (where your mtasa-blue is located) and delete the `.vs` folder. Start Visual Studio and everything should be fixed. | |||
=== Git Client === | === Git Client === | ||
Line 65: | Line 104: | ||
# Open the solution file '''MTASA.sln''' in the '''Build''' directory | # Open the solution file '''MTASA.sln''' in the '''Build''' directory | ||
# If you are asked to upgrade the project, click '''Cancel''' | # If you are asked to upgrade the project, click '''Cancel''' | ||
# | # Select '''Debug''' - '''Win32''' configuration in Visual Studio, then press Build > Build Solution... (may take some minutes) | ||
# Execute the script '''win-install-data.bat''' | # Execute the script '''win-install-data.bat''' | ||
Line 82: | Line 121: | ||
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 [https://github.com/multitheftauto/mtasa-resources hosted on GitHub]. You can download the latest resources from there or [http://mirror. | 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.multitheftauto.com/mtasa/resources/ download a zipped version]. Make sure that you have the latest resources package. | ||
=== Starting the server === | === Starting the server === | ||
Line 90: | Line 129: | ||
== Debugging == | == Debugging == | ||
If you already compiled the code in the '''Debug''' configuration then continue reading, if not, then go up to ''Compiling the code'' and follow the steps for a ''Debug'' build.<br> | If you already compiled the code in the '''Debug''' configuration then continue reading, if not, then go up to ''Compiling the code'' and follow the steps for a ''Debug'' build.<br> | ||
To compile in '''Release''', click on the '''Debug''' list and switch to '''Release'''.<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> | 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> | ||
[[File:Local_Windows_Debugger.PNG]] | [[File:Local_Windows_Debugger.PNG]] | ||
Line 100: | Line 140: | ||
=== Extending timeout duration === | === Extending timeout duration === | ||
When you use breakpoints during debugging, you may get kicked by the server due to timeout, because the client is frozen. To prevent this, create the '''timeout.longtime''' file in your ''Bin/server/'' directory. | When you use breakpoints during debugging, you may get kicked by the server due to timeout, because the client is frozen. To prevent this, create the '''timeout.longtime''' file in your ''Bin/server/'' directory. | ||
The content of the file is the new timeout duration in seconds, so make sure you type a huge number in there. If you keep the file empty, the timeout will be set to 120 seconds. | The content of the file is the new timeout duration in seconds<!-- | ||
Actually, its 60 milliseconds? When setting the content to "600", it should be 600 seconds (10 minutes) but the timeout is being set to 36000 seconds (36000 / 600 = 60 ms) | |||
-->, so make sure you type a huge number in there. If you keep the file empty, the timeout will be set to 120 seconds. | |||
=== ReAttach for Visual Studio === | === ReAttach for Visual Studio === | ||
Line 110: | Line 152: | ||
= Additional information = | = Additional information = | ||
If you need more information, try our [ | If you need more information, try our [https://github.com/multitheftauto/mtasa-blue/issues bug tracker] or [https://discord.com/invite/mtasa Discord]. | ||
= Errors = | = Errors = | ||
Line 122: | Line 164: | ||
Solution: Execute '''win-install-data.bat''' in main directory. | Solution: Execute '''win-install-data.bat''' in main directory. | ||
[[ | == ERROR: Loading network library (net_d.dll) failed! == | ||
Solution: Execute '''win-install-data.bat''' in main directory. | |||
[[pl:Compiling MTASA]] | |||
[[pt-br:Compilando o MTASA]] | [[pt-br:Compilando o MTASA]] | ||
[[ru:Compiling MTASA]] | [[ru:Compiling MTASA]] | ||
[[Category: Development]] | [[Category: Development]] |
Latest revision as of 13:27, 2 October 2024
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
Compiling the Multi Theft Auto client is only supported on Windows 10.
Make sure you have the following software and SDKs installed:
Visual Studio 2022
- Download Microsoft Visual Studio 2022 - make sure you get the Community Edition, that one is free.
- On the installation checklist, make sure you tick these 2 items:
- Desktop development with C++
- Optional component C++ MFC for latest v143 build tools (x86 & x64)
If you don't enable MFC, you will get the following error: cannot open include file 'afxres.h'
.
If you've made a mistake, you can run the Visual Studio Installer app to modify your current installation. There is no need to uninstall and reinstall.
Microsoft DirectX SDK
Download Microsoft DirectX SDK (August 2009) (DXSDK_Aug09.exe):
Algorithm and variant | Hash | |
---|---|---|
SHA-3 | SHA3-224 | 8bfcdc03518d7edd34689534fd4d21291469ff2f2eb10437ad648c58 |
SHA3-256 | 45bf3e08da3b3636ddb4f4a74243430f8d65759c074c0d79756ef810c4701c5a | |
SHA3-384 | b358e529963d6f5fd7f8bd4b530fb18f6a2e6a442009a54e981b2f9967589ed48150af310f283640d56f9b60d41100c9 | |
SHA3-512 | 43522187053af744250059ef69c0f3083cecd1157fe56daac16b9497ebc6fb5b525875144e42898367c55f757cffd3526f37074d544470578602a5a944a45a75 | |
SHAKE128 | 2a7c81bde9e867cbb5ef00b72ad8de66a3ee64c1d59f16465fa712479b6a84d28a02cc5ed08afa1d51e72011657453dbd4656cc9340d32e18179c39d03982dfc35c8f0c2a5c99e11dc74d0e23ed21b1e55f19c809a5a152bde39a2d46fcd12421f373f2d691ade1b57faf6c2ab7aded5a7d174f1f1c77127c0d6a1523b4775c569c5e1b4efa2da4bf2f708a96707a709e245a7f507382e69a81777919c90e95a091c0b699ce7f517 | |
SHAKE256 | 9c100dac5245a61774f3a2752bf9e941bdcd5654b18035155161c63b20936dfc9bd7334feb9a6fe9a99a65491161083b39ac3bd578e2cf4f90cba3c786e9924fa0611f65a725331b77b63e7c8b552e1637bc77531ba0f2c9cac72115b28e523929ede4e5b246a0755e8d5c4089d94bf16627fb08672cfffa523bba3d976489a0eec60d3c6a96ca2b | |
SHA-2 | SHA-224 | a3a74b89cccfe314b79418d5598aac5e94800221e5d945c74f15c004 |
SHA-256 | 4ab1de69312f10f6b41310a5218d80c478bbd823bc0f86627318d690b128fb9f | |
SHA-384 | 254ed29c6ad2cadc6f013d2d51c0ac78a6bbe236a2c94ca99610eba8b2c1200d1a62c445ca9ee51bb09354875d5eca8a | |
SHA-512 | 736393c0dfa32221e229890f87eb330174d70dd2a02fa0cace303816d3e7a10a332a44129748de39665d1b339e627d6028c2080268f7afdd5240c447fec8ff0b | |
SHA-512/224 | 7e23d9ba916000782a17e23abf48e25237f45590cfe767aed9d79f10 | |
SHA-512/256 | 0c833a56046fe7e4213fcb1862c730acf313d1b8f60b51eebf64dc3e79730c1c | |
MD5 | 66e5379ecf46b014688779621bcc677c | |
SHA-1 | 5b9b969ed7b6cf5534bb7350e44c09b3573b0e71 | |
CRC32 | e9f5c61d |
NOTE: Restart your computer after installing Microsoft DirectX SDK, because otherwise the environment variable DXSDK_DIR won't be available yet. After restarting it re-run create-projects.bat
Cant find d3dx9.h
Add the $(DXSDK_DIR)Include; to the VC++ Directories in DirectX9GuiRenderer, GUI and Client Core projects.
You can find the VC++ Directories list by selecting a project, then pressing the shortcut ALT + ENTER (without the +), then under the 'Configuration properties' you can find 'VC++ Directories', and in there you can find the 'Include Directories' field, click on it and add ;$(DXSDK_DIR)Include; at the end of it.
Note: You need to do the same thing in Release mode as well
Cant find d3dx9.lib
Do do same as in the error above, but instead of ;$(DXSDK_DIR)Include; you must add ;$(DXSDK_DIR)Lib/x86; to the Library directories field
Note: You need to do the same thing in Release mode as well
S1023 Error
"S1023" error when you install the DirectX SDK (June 2010)
Cannot open source file "xxx.h" after upgrading to Visual Studio 2022
If you've just upgraded to Visual Studio 2022 and were working on MTA using a previous version, you may receive errors about header files not being found (stdio.h, stddef.h, etc) when building the project.
Make sure you have the latest Windows 10 SDK installed (via the Visual Studio Installer) and restart your PC.
If that doesn't work - close Visual Studio, go into the `Build` folder (where your mtasa-blue is located) and delete the `.vs` folder. Start Visual Studio and everything should be fixed.
Git Client
If you would like to contribute to MTA, you should install Git. This will allow you to collaborate with us by creating branches and pushing to your own fork. If you are not comfortable with the command line, we recommend you to download and install GitHub Desktop.
If you only want to compile the source code and are not interested in contributing to MTA, you can download the source directly (see below).
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.
- Repository: multitheftauto/mtasa-blue
- .zip: master.zip
- .tar.gz: master.tar.gz
Compiling the code
- Execute the script win-create-projects.bat
- Open the solution file MTASA.sln in the Build directory
- If you are asked to upgrade the project, click Cancel
- Select Debug - Win32 configuration in Visual Studio, then press Build > Build Solution... (may take some minutes)
- Execute the script win-install-data.bat
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 Debugging below).
Running the dedicated server
If you already have run step 5 (Install resources) in Compiling the code to install resources then you can go to 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 with the Visual Studio Debugger (as of writing, you can do that by right-clicking on the Server's Launcher project and selecting Start a local instance in the Debugger menu), but you can also attach to a running debug build MTA server (see more in the section Debugging below).
Debugging
If you already compiled the code in the Debug configuration then continue reading, if not, then go up to Compiling the code and follow the steps for a Debug build.
To compile in Release, click on the Debug list and switch to Release.
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.
How to enable breakpoints
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 besides the MTA Launcher project.
Extending timeout duration
When you use breakpoints during debugging, you may get kicked by the server due to timeout, because the client is frozen. To prevent this, create the timeout.longtime file in your Bin/server/ directory. The content of the file is the new timeout duration in seconds, so make sure you type a huge number in there. If you keep the file empty, the timeout will be set to 120 seconds.
ReAttach for Visual Studio
You can use ReAttach to re-attach the debugger to the gta_sa.exe executable whenever you start your local debugger in Visual Studio.
Getting involved
Please see our Coding guidelines for information on the coding practice.
Additional information
If you need more information, try our bug tracker or Discord.
Errors
CL38 error. [netc_d.dll not found]
Solution: Delete Multi Theft Auto_d.exe and hit compile again.
After cloning the repository, it doesn't compile the project
Solution: Execute win-create-projects.bat in main directory.
CL17 Load field. Please ensure that the latest data files have been installed correctly
Solution: Execute win-install-data.bat in main directory.
ERROR: Loading network library (net_d.dll) failed!
Solution: Execute win-install-data.bat in main directory.