Building MTASA Server on GNU Linux: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(25 intermediate revisions by 12 users not shown)
Line 1: Line 1:
== Compiling or Running on a 64 bit Linux ==
{{Needs Checking|Confirm steps work.}}
Additional steps for compiling or running a MTA server on 64 bit Linux:
 
===Install 32 bit libs for your distro===
== Installing and Running MTASA server on Linux ==
For Debian, this is achieved with:
{{Note|This article is only for developers who changed the server code. If you are looking for the precompiled server (for normal server owners). Go to: [http://linux.mtasa.com/ linux.mtasa.com] and see [[Installing and Running MTASA Server on GNU_Linux]]}}
 
<!--
== Compiling on a 64 bit Linux ==
Additional steps for compiling a MTA server on 64 bit Linux:
===Install 32 bit libs for your 64 bit distro===
For 64 bit Debian, this is achieved with:


  apt-get install ia32-libs
  apt-get install ia32-libs


===Troubleshooting===
===64 bit Troubleshooting===
* If you get a problem with such as "libreadline.so.5: cannot open shared object file: No such file or directory.", it can be solved on Debian by doing this:
* If you get a problem with such as "libreadline.so.5: cannot open shared object file: No such file or directory.", it can be solved on 64 bit Debian Squeeze  by doing this:


  wget <nowiki>http</nowiki>://ftp.uk.debian.org/debian/pool/main/r/readline5/libreadline5_5.2-7_i386.deb
  apt-get install lib32readline5
dpkg -X libreadline5_5.2-7_i386.deb temp
cp -d temp/lib/libreadline.so.5* /usr/lib32/


* If you get a problem with such as "libncursesw.so.5: cannot open shared object file: No such file or directory", it can be solved on Debian Squeeze by doing this:
* If you get a problem with such as "libncursesw.so.5 cannot open shared object file: No such file or directory", it can be solved on 64 bit Debian Squeeze by doing this:


  apt-get install lib32ncursesw5
  apt-get install lib32ncursesw5


* Further 64 bit solutions can be found [http://forum.mtasa.com/viewtopic.php?f=106&t=35328#p367282 on the forums]
* Further 64 bit solutions can be found [http://forum.mtasa.com/viewtopic.php?f=106&t=35328#p367282 on the forums]
* If you are using Cent OS and you get something like /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by xmll.so) this can be resolved by doing downloading the archive [[http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/9/Fedora/i386/os/Packages/libstdc++-4.3.0-8.i386.rpm here]] and unpacking it with the following command:
* If you are using Cent OS and you get something like /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by xmll.so) this can be resolved by doing downloading the archive [[http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/9/Fedora/i386/os/Packages/libstdc++-4.3.0-8.i386.rpm here]] and unpacking it with the following command:


  rpm2cpio libstdc++-4.3.0-8.i386.rpm | cpio -i --make-directories
  rpm2cpio libstdc++-4.3.0-8.i386.rpm | cpio -i --make-directories
 
-->
 
 
== Preparing your system ==
== Preparing your system ==


In order to build the Multi Theft Auto dedicated server, you will have to set up your system with the correct libraries and tools. How these are installed depends on your distribution.
In order to build the Multi Theft Auto dedicated server, you will have to set up your system with the correct libraries and tools. How these are installed depends on your distribution.


Our network module (net.dll or net.so) is distributed as a precompiled binary library. The file for GNU/Linux can be found inside the lastest Linux nightly from [http://nightly.mtasa.com/ here]. Use the net.so from 1.4 if you are compiling from the trunk, or the net.so from 1.3.x if you are compiling the 1.3.x branch. Be sure the read the top of ''MTA10_Server/version.h'' as it contains directions on how to compile the different build types.
Our network module (net.dll or net.so) is distributed as a precompiled binary library. The file for GNU/Linux can be found inside the lastest Linux nightly from [http://nightly.mtasa.com/ here]. Use the net.so from {{Current Version|master}} if you are compiling from the trunk, or the net.so from {{Current Version|full}} if you are compiling the {{Current Version|full}} branch. Be sure the read the top of ''Server/version.h'' as it contains directions on how to compile the different build types.
{{Note|This article is only for developers who changed the server code, if you are looking for the precompiled server (for normal server owners). Go to: [http://linux.mtasa.com/ linux.mtasa.com]}}


=== Debian Linux ===
=== Debian Linux ===
Includes derivative distributions such as Ubuntu.
Includes derivative distributions such as Ubuntu.


Line 39: Line 42:
* '''automake:''' contains the automake tools
* '''automake:''' contains the automake tools
* '''libtool:''' contains the libtool software required to build libraries
* '''libtool:''' contains the libtool software required to build libraries
<!--
* '''libcurl3-dev:''' contains the cURL library (version 3 without SSL support)
* '''libcurl3-dev:''' contains the cURL library (version 3 without SSL support)
* '''libpcre3-dev:''' contains the PCRE library (version 3)
* '''libpcre3-dev:''' contains the PCRE library (version 3)
* '''libsqlite3-dev:''' contains the SQLite library (version 3)
* '''libsqlite3-dev:''' contains the SQLite library (version 3)
* '''libreadline5-dev:''' contains the readline library (version 5)
-->
* '''subversion:''' contains the SVN client used to check out our code repository
* '''libreadline-gplv2-dev:''' contains the readline library (version 5)
* '''libncurses5-dev:''' contains software for controlling writing to the console screen
* '''libncurses5-dev:''' contains software for controlling writing to the console screen
* '''libncursesw5-dev:''' contains support for wide characters
* '''libncursesw5-dev:''' contains support for wide characters
<!--
* '''libsparsehash-dev:''' contains support for Google's hash-map '''(So you don't have to compile sparehash!)'''
* '''libsparsehash-dev:''' contains support for Google's hash-map '''(So you don't have to compile sparehash!)'''
* '''libmysqlclient-dev:''' contains the MySQL library
-->
* '''default-libmysqlclient-dev:''' contains the MySQL library
* '''git:''' contains the git client used to check out our code repository
* '''unzip:''' contains archive unpacker
To install these packages through apt, use the apt-get install <package list> command as in the following example (execute as root):
To install these packages through apt, use the apt-get install <package list> command as in the following example (execute as root):


  apt-get install build-essential automake libtool libcurl4-openssl-dev libpcre3-dev
  apt-get install build-essential automake libtool
  apt-get install libsqlite3-dev libreadline5-dev subversion libncurses5-dev
apt-get install libreadline-gplv2-dev libncurses5-dev libncursesw5-dev
apt-get install libncursesw5-dev libsparsehash-dev libmysqlclient-dev
  apt-get install default-libmysqlclient-dev git unzip
 
Note: On Debian 8 systems please use this: '''apt-get install build-essential automake libtool libreadline-gplv2-dev libncurses5-dev libncursesw5-dev libmysqlclient-dev git unzip'''


=== Gentoo Linux ===
=== Gentoo Linux ===
You will need the necessary build tools, headers and libraries. Because Gentoo’s portage system is designed to compile any packages on your own system, the necessary build tools will have already been installed. This only leaves you to install the necessary libraries:
You will need the necessary build tools, headers and libraries. Because Gentoo’s portage system is designed to compile any packages on your own system, the necessary build tools will have already been installed. This only leaves you to install the necessary libraries:


<!--
* '''sqlite:''' contains the SQLite library
* '''sqlite:''' contains the SQLite library
* '''subversion:''' contains the SVN client used to check out our code repository
* '''curl:''' contains the cURL library; to compile with SSL support, apply the net-misc/curl SSL USE flag
* '''curl:''' contains the cURL library; to compile with SSL support, apply the net-misc/curl ssl USE flag
-->
To compile and install these packages through emerge, use the emerge -v <package list> command. The -v option shows additional * * information and can be omitted. (If you want to use any USE flags, prepend emerge with USE="use flags here". You can also use the -pv option to verify that you’re using the correct flags.) Refer to the [http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=1 Gentoo Handbook] or manual for more information on emerge.
* '''git:''' contains the git client used to check out our code repository
To compile and install these packages through ''emerge'', use the '''emerge -v <package list>''' command. The -v option shows additional * * information and can be omitted. (If you want to use any USE flags, prepend emerge with USE="use flags here". You can also use the -pv option to verify that you’re using the correct flags.) Refer to the [http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=1 Gentoo Handbook] or manual for more information on emerge.


Example:
Example:


  emerge -v subversion sqlite
  emerge -v git sqlite
  USE=“net-misc/curl ssl” emerge -v curl
  USE=“net-misc/curl ssl” emerge -v curl


Line 72: Line 84:
You will need these packages to be able to successfully compile a MTA server on Fedora:  
You will need these packages to be able to successfully compile a MTA server on Fedora:  
* '''glibc-devel:'''
* '''glibc-devel:'''
<!--
* '''curl-devel:''' contains the cURL library
* '''curl-devel:''' contains the cURL library
* '''pcre-devel:''' contains the PCRE library
* '''pcre-devel:''' contains the PCRE library
* '''sqlite3-devel:''' contains the SQLite library
* '''sqlite3-devel:''' contains the SQLite library
-->
* '''readline-devel:''' contains the readline library
* '''readline-devel:''' contains the readline library
<!--
* '''lua-devel:''' contains the Lua libraries
* '''lua-devel:''' contains the Lua libraries
* '''subversion:''' contains the SVN client to check out the source code
-->
* '''git:''' contains the git client to check out the source code
To install these packages through yum, use the yum install <package list> command as in the following example (execute as root):
To install these packages through yum, use the yum install <package list> command as in the following example (execute as root):


  yum install glibc-devel curl-devel pcre-devel sqlite3-devel readline-devel lua-devel subversion
  yum install glibc-devel readline-devel git
 
 
== Compiling on 64-bit ==
The MTA:SA server currently cannot be properly compiled in 64-bit mode. Instead, you should compile it in 32-bit mode and run it using 32-bit compatibility mode (use the '''-m32''' flag as show below).
Also ensure you have cross compilers installed. On Debian this can be achieved with:
 
apt-get install gcc-multilib g++-multilib


 
== General instructions for {{Current Version|master}} ==
== General instructions for {{Current Version|full}} ==


'''Downloading the source.'''
'''Downloading the source.'''


First you need to download the source.
First, you need to download the source. Either clone as shown below or [https://github.com/multitheftauto/mtasa-blue/archive/master.zip download a zip snapshot]


  svn checkout <nowiki>http</nowiki>://mtasa-blue.googlecode.com/svn/branches/{{Current Version|full}}/ mtasa-blue
  git clone <nowiki>https</nowiki>://github.com/multitheftauto/mtasa-blue.git mtasa-blue
  cd mtasa-blue
  cd mtasa-blue


Then compile it thus:
Then compile it thus:


  autoreconf -fiv
  ./linux-build.sh
export PKG_CONFIG_PATH=/usr/lib32/pkgconfig
./configure LDFLAGS="-m32" CPPFLAGS="-m32" CFLAGS="-m32" CXXFLAGS="-m32" $@
make
make -C MTA10_Server install
make -C Shared/XML install
 
Get the net.so like this:
 
wget <nowiki>http</nowiki>://nightly.mtasa.com/?multitheftauto_linux-{{Current Version|full}}-rc-latest -O multitheftauto_linux-{{Current Version|full}}-latest.tar.gz
tar -xzf multitheftauto_linux-{{Current Version|full}}-latest.tar.gz --transform 's:[^/]*:latest_nightly:'
mv latest_nightly/net.so MTA10_Server/output/
rm -rf latest_nightly multitheftauto_linux-{{Current Version|full}}-latest.tar.gz
 
Copy config files:
 
cp MTA10_Server/mods/deathmatch/acl.xml MTA10_Server/output/mods/deathmatch/acl.xml
cp MTA10_Server/mods/deathmatch/mtaserver.conf MTA10_Server/output/mods/deathmatch/mtaserver.conf


Get resources:
Then copy the configuration files, network module and resources into '''Bin/server''' by running this command:


  svn export <nowiki>http</nowiki>://mtasa-resources.googlecode.com/svn/trunk/ MTA10_Server/output/mods/deathmatch/resources
  ./linux-install-data.sh


And the server should be ready in MTA10_Server/output
And the resources and stuff should be downloaded and stuff. As well as the net_d.dll file.


=== '''Troubleshooting''' ===
=== '''Troubleshooting''' ===


Any errors during the compilation of json-c can be solved by calling autoreconf -fi from the json-c directory.
If you’re getting any unexpected errors while compiling, please check our [https://github.com/multitheftauto/mtasa-blue/issues GitHub issues] or our [https://discord.com/invite/GNN6PRtTnu development-focused Discord server].
 
If you’re getting any unexpected errors while compiling, please check our [http://bugs.mtasa.com/ Bug tracker] or our [irc://irc.multitheftauto.com/ IRC channel]
 
 
== '''Server crashes''' ==
 
If your Linux server crashes, please obtain a backtrace and post a report on our [http://bugs.mtasa.com/ Bug tracker]
 
====To obtain a backtrace:====
===Do you have a core dump file in the the MTA server directory?===
It's usually called 'core', and usually over 100MB, and looks something like this:
[[Image:Core.png]]
====If you have a core dump file in the the MTA server directory:====
*Install gdb. To install gdb on Debian, use this command:
apt-get install gdb
*And from the MTA install directory do this command
gdb mta-server -c core
*When gdb launches, do this command to get a  module list:
i sh
*And then this command to get a backtrace:
bt
*Save the output
*(To exit gdb, use the quit command)
 
====If you do not have a core dump file in the the MTA server directory:====
*Install gdb. To install gdb on Debian, use this command:
apt-get install gdb
*And from the MTA server directory start the mta-server like this:
gdb mta-server --eval-command run
*Now wait for a crash. (Ignore weird screen output in the meantime)
*When a crash occurs, do this command to get a module list:
i sh
*And then this command to get a backtrace:
bt
*Save the output
*(To exit gdb, use the quit command)
 
 
== '''Server freezes''' ==
 
If your Linux server freezes, please obtain a backtrace with thread information and post a report on our [http://bugs.mtasa.com/ Bug tracker]
 
====To obtain a backtrace with thread information:====
*Install gdb. To install gdb on Debian, use this command:
apt-get install gdb
*And from the MTA server directory start the mta-server like this:
gdb mta-server --eval-command run
*Now wait for a freeze. (Ignore weird screen output in the meantime)
*When a freeze occurs, press ctrl-c to start gdb
*Then do this command to get a module list:
i sh
*And then this command to get a backtrace:
bt
*And then this command to get thread information:
info threads
*Save the output
*(To exit gdb, use the quit command)


<ul>
<li>If you get a message saying "Killed" when running premake5 gmake (linux-build.sh), that usually means you ran out of memory.<br />
You can confirm this by searching for kill logs by running <code>sudo dmesg | grep -i kill</code><br />
A possible solution for this might be to [https://opensource.com/article/18/9/swap-space-linux-systems turn on swap] or upgrade your system memory temporarily.<br />
1 GB is likely '''not''' enough of memory to complete the build.
</li>
</ul>


[[ru:Building MTASA Server on GNU Linux]]
[[ru:Building MTASA Server on GNU Linux]]
[[Category: Development]]

Latest revision as of 22:18, 23 April 2022

Dialog-information.png This article needs checking.

Reason(s): Confirm steps work.

Installing and Running MTASA server on Linux

[[{{{image}}}|link=|]] Note: This article is only for developers who changed the server code. If you are looking for the precompiled server (for normal server owners). Go to: linux.mtasa.com and see Installing and Running MTASA Server on GNU_Linux

Preparing your system

In order to build the Multi Theft Auto dedicated server, you will have to set up your system with the correct libraries and tools. How these are installed depends on your distribution.

Our network module (net.dll or net.so) is distributed as a precompiled binary library. The file for GNU/Linux can be found inside the lastest Linux nightly from here. Use the net.so from 1.6 if you are compiling from the trunk, or the net.so from 1.6.0 if you are compiling the 1.6.0 branch. Be sure the read the top of Server/version.h as it contains directions on how to compile the different build types.

Debian Linux

Includes derivative distributions such as Ubuntu.

You will need the necessary build tools, headers and libraries, which are distributed through the following Debian packages (e.g. Debian Lenny):

  • build-essential: contains the necessary tools, headers and libraries to build applications
  • automake: contains the automake tools
  • libtool: contains the libtool software required to build libraries
  • libreadline-gplv2-dev: contains the readline library (version 5)
  • libncurses5-dev: contains software for controlling writing to the console screen
  • libncursesw5-dev: contains support for wide characters
  • default-libmysqlclient-dev: contains the MySQL library
  • git: contains the git client used to check out our code repository
  • unzip: contains archive unpacker

To install these packages through apt, use the apt-get install <package list> command as in the following example (execute as root):

apt-get install build-essential automake libtool
apt-get install libreadline-gplv2-dev libncurses5-dev libncursesw5-dev
apt-get install default-libmysqlclient-dev git unzip

Note: On Debian 8 systems please use this: apt-get install build-essential automake libtool libreadline-gplv2-dev libncurses5-dev libncursesw5-dev libmysqlclient-dev git unzip

Gentoo Linux

You will need the necessary build tools, headers and libraries. Because Gentoo’s portage system is designed to compile any packages on your own system, the necessary build tools will have already been installed. This only leaves you to install the necessary libraries:

  • git: contains the git client used to check out our code repository

To compile and install these packages through emerge, use the emerge -v <package list> command. The -v option shows additional * * information and can be omitted. (If you want to use any USE flags, prepend emerge with USE="use flags here". You can also use the -pv option to verify that you’re using the correct flags.) Refer to the Gentoo Handbook or manual for more information on emerge.

Example:

emerge -v git sqlite
USE=“net-misc/curl ssl” emerge -v curl

Fedora

You will need these packages to be able to successfully compile a MTA server on Fedora:

  • glibc-devel:
  • readline-devel: contains the readline library
  • git: contains the git client to check out the source code

To install these packages through yum, use the yum install <package list> command as in the following example (execute as root):

yum install glibc-devel readline-devel git

General instructions for 1.6

Downloading the source.

First, you need to download the source. Either clone as shown below or download a zip snapshot

git clone https://github.com/multitheftauto/mtasa-blue.git mtasa-blue
cd mtasa-blue

Then compile it thus:

./linux-build.sh

Then copy the configuration files, network module and resources into Bin/server by running this command:

./linux-install-data.sh

And the resources and stuff should be downloaded and stuff. As well as the net_d.dll file.

Troubleshooting

If you’re getting any unexpected errors while compiling, please check our GitHub issues or our development-focused Discord server.

  • If you get a message saying "Killed" when running premake5 gmake (linux-build.sh), that usually means you ran out of memory.
    You can confirm this by searching for kill logs by running sudo dmesg | grep -i kill
    A possible solution for this might be to turn on swap or upgrade your system memory temporarily.
    1 GB is likely not enough of memory to complete the build.