Compiling under Linux: Difference between revisions
Bloodykenny (talk | contribs) (→Setting up the Makefile: remove overly speculative commentary) |
m (Setting bug notice hidetested=1 param on page where the bug might not need tested in param specified) |
||
(41 intermediate revisions by 23 users not shown) | |||
Line 1: | Line 1: | ||
{{LanguageBar}} | |||
= | {{Outdated sdk|{{src07|4.1}}|newer-sdk={{src13|4.1}}|newer-sdk-equivalent=[[Source_SDK_Base_2013#Setting_up_&_compiling_code|Setting up Source 2013 (Platform Specific)]]}} | ||
{{cleanup}} | |||
{{toc-right}} | |||
'''Creating a Linux build''' of your multiplayer [[dedicated server]] or [[server plugin]] is not required, but does make it much more likely to be accepted by commercial server operators. | |||
Building on Linux requires an existing Visual Studio project, which is converted to a makefile by Valve's <code>vcpm</code> tool ("Visual C++ Project to Make"). | |||
== Getting Linux == | |||
If you are unsure which version of Linux to use, go for [http://www.ubuntu.com/ Ubuntu], which tries to be user-friendly. It has a "software centre" that makes installing packages simple, and can be run from a CD if you want to experiment (but you'll want to install it permanently before you start digging in). | |||
== Requirements == | |||
* [http://gcc.gnu.org GCC and G++ 4.2.x] or lower | |||
* [[Vprojtomake 2010]] '''or''' [http://xml.apache.org/xerces-c/ Xerces XML parser] 2.8.x | |||
* <code>libstdc++</code> 6 | |||
* <code>libc</code> 2.4 or higher | |||
If you are running 64-bit Linux: | |||
<code> | * <code>ia32-libs</code> (or you will be told that 32-bit binaries don't exist) | ||
* GCC multilib for your GCC release | |||
* Make sure you have the 32-bit build of Xerces, if you haven't upgraded to Vprojtomake 2010. | |||
== Setting up == | |||
{{bug|hidetested=1|Don't use <code>~</code> for your home directory. Parts of the make process do not understand it.}} | |||
< | Open <code>sdk_root/linux_sdk/Makefile</code>. Most of the config options here are straightforward, except for: | ||
; <code>MOD_CONFIG</code> | |||
- | : These values should come straight out of your VS project. Remove all whitespace. To build the 'My Server' project in release mode, this should read <code>MyServer_ReleaseWin32</code>. | ||
; <code>GAME_DIR</code> | |||
: To get this, you need to download a [[dedicated server]] from Valve. You need the <code>orangebox</code> game. | |||
; <code>CC</code>, <code>CPLUS</code>, <code>CLINK</code> | |||
: Change these to read "gcc -m32" or "g++ -m32", with quotes. If your system's default build of GCC is too recent, specify an older version with "gcc-4.2 -m32" or similar; check <code>/usr/bin</code> to see what you've got installed. | |||
; <code>CPP_LIB</code> | |||
: These files may not be where Valve think they are. To find them, browse to <code>/usr/lib</code> and search. 64-bit users will encounter two version of each file; choose the ones in the '32' folder. | |||
* [[Server plugin]]s need extra configuration. See [[Server plugins#Compiling]]. | |||
* Experienced GCC programmers may be interested in [[SDK Known Issues List#Getting the SDK to work under -Wall -Werror|Getting the SDK to work under -Wall -Werror]]. | |||
== Making == | |||
Once everything is configured correctly, you can build your mod by navigating to the <code>linux_sdk</code> folder and performing a <code>make</code>. | |||
{{note|If you've done a lot of development on Windows you are likely to encounter "No such file or directory" or "no rule to make target" errors (if you get a mess of errors, scroll up to the very first one). These should all be down to two easily-rectified issues: | |||
* Paths are case-sensitive in Linux. <code>/Multiplayer</code> is not the same as <code>/multiplayer</code> | |||
* Paths must delimited with <code>/</code> characters in Linux, not Windows' <code>\</code>. | |||
</ | |||
Making these changes to your source files will not affect compiling on Windows.}} | |||
== Running == | |||
To run the mod perform <code>make install</code> to copy the server binary to your mod's folder, then cd into your dedicated server folder and do <code>./srcds_run</code> with the appropriate <code>-game</code> parameter. | |||
To run the mod | |||
<!-- 2.4 was released in 2006, and can be assumed present on modern-day Linux systems | |||
=== | == libc == | ||
The version of the C runtime library on a system running your server code can affect stability. To look at the requirements of your binary, examine the last section of the output of this command: | |||
= | <source lang=bash> | ||
readelf -V your_server.so | |||
</source> | |||
The highest version of GLIBC reported is the one that your binary requires. You will have to consider where to draw the line between backwards-compatibility and functionality; as the SDK stands the highest version you will see is probably 2.4, [http://ftp.gnu.org/gnu/glibc/?C=M;O=D which was released in 2006] and is highly likely to be present on target systems. | |||
If you want to see precisely which functions require a given version of libc, run the following: | |||
<source lang=bash> | |||
nm your_server.so | grep GLIBC_<VERSION> | |||
</source> | |||
--> | |||
[[Category:Programming]] | |||
[[Category:Linux]] | |||
Latest revision as of 07:07, 20 May 2025


If you are using


For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.
Creating a Linux build of your multiplayer dedicated server or server plugin is not required, but does make it much more likely to be accepted by commercial server operators.
Building on Linux requires an existing Visual Studio project, which is converted to a makefile by Valve's vcpm
tool ("Visual C++ Project to Make").
Getting Linux
If you are unsure which version of Linux to use, go for Ubuntu, which tries to be user-friendly. It has a "software centre" that makes installing packages simple, and can be run from a CD if you want to experiment (but you'll want to install it permanently before you start digging in).
Requirements
- GCC and G++ 4.2.x or lower
- Vprojtomake 2010 or Xerces XML parser 2.8.x
libstdc++
6libc
2.4 or higher
If you are running 64-bit Linux:
ia32-libs
(or you will be told that 32-bit binaries don't exist)- GCC multilib for your GCC release
- Make sure you have the 32-bit build of Xerces, if you haven't upgraded to Vprojtomake 2010.
Setting up

~
for your home directory. Parts of the make process do not understand it.Open sdk_root/linux_sdk/Makefile
. Most of the config options here are straightforward, except for:
MOD_CONFIG
- These values should come straight out of your VS project. Remove all whitespace. To build the 'My Server' project in release mode, this should read
MyServer_ReleaseWin32
. GAME_DIR
- To get this, you need to download a dedicated server from Valve. You need the
orangebox
game. CC
,CPLUS
,CLINK
- Change these to read "gcc -m32" or "g++ -m32", with quotes. If your system's default build of GCC is too recent, specify an older version with "gcc-4.2 -m32" or similar; check
/usr/bin
to see what you've got installed. CPP_LIB
- These files may not be where Valve think they are. To find them, browse to
/usr/lib
and search. 64-bit users will encounter two version of each file; choose the ones in the '32' folder.
- Server plugins need extra configuration. See Server plugins#Compiling.
- Experienced GCC programmers may be interested in Getting the SDK to work under -Wall -Werror.
Making
Once everything is configured correctly, you can build your mod by navigating to the linux_sdk
folder and performing a make
.

- Paths are case-sensitive in Linux.
/Multiplayer
is not the same as/multiplayer
- Paths must delimited with
/
characters in Linux, not Windows'\
.
Running
To run the mod perform make install
to copy the server binary to your mod's folder, then cd into your dedicated server folder and do ./srcds_run
with the appropriate -game
parameter.