Compiling SDK Linux: Difference between revisions
Created page with "<p>You should know a little bit about linux before you can do this.<br />Kingpin in the past only compiled under gcc 2.7.2.3 compiler.<br />You mostly only get gcc 2.7.2.3 compiler under [https://en.wikipedia.org/wiki/Red_Hat_Linux Redhat 5.2]<br />Maybe that was the Linux version that Xatrix used.<br />But I'm going to use a debian linux system [https://xubuntu.org/ Xunbuntu] (Based on [https://ubuntu.com/ Ubuntu] but loads faster and easyr in a [https://en.wikiped..." |
No edit summary |
||
Line 1: | Line 1: | ||
<p>You should know a little bit about linux before you can do this.<br />Kingpin in the past only compiled under gcc 2.7.2.3 compiler.<br />You mostly only get gcc 2.7.2.3 compiler under [https://en.wikipedia.org/wiki/Red_Hat_Linux Redhat 5.2]<br />Maybe that was the Linux version that Xatrix used.<br />But I'm going to use a debian linux system [https://xubuntu.org/ Xunbuntu] (Based on [https://ubuntu.com/ Ubuntu] but loads faster and easyr in a [https://en.wikipedia.org/wiki/VirtualBox VirtualBox])</p> | <p>You should know a little bit about linux before you can do this.<br />Kingpin in the past only compiled under gcc 2.7.2.3 compiler.<br />You mostly only get gcc 2.7.2.3 compiler under [https://en.wikipedia.org/wiki/Red_Hat_Linux Redhat 5.2]<br />Maybe that was the Linux version that Xatrix used.<br />But I'm going to use a debian linux system [https://xubuntu.org/ Xunbuntu] (Based on [https://ubuntu.com/ Ubuntu] but loads faster and easyr in a [https://en.wikipedia.org/wiki/VirtualBox VirtualBox])</p> | ||
<hr | <hr> | ||
<p>If you're using [https://en.wikipedia.org/wiki/Red_Hat_Linux Redhat 5.2] for some reasson (not really recommend) the orginale command line to compile gamei386.so was:< | <p>If you're using [https://en.wikipedia.org/wiki/Red_Hat_Linux Redhat 5.2] for some reasson (not really recommend) the orginale command line to compile gamei386.so was:</p> | ||
<hr | <syntaxhighlight lang="bash"> | ||
<p>First of all you need gcc. Open a terminal:< | gcc *.c *.o -s -m486 -O6 -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 -malign-jumps=2 -malign-functions=2 -fPIC -shared -o gamei386.so | ||
<p>Width [https://www.kingpin.info/download/index.php?dir=kingpin/server/official/sdk/&file=kpsdk.zip kpsdk.zip] there some problems you need to fix.<br />Unzip the gamesrc to some folder.<br />Make everything lowercase in the folder with [https://www.kingpin.info/download/index.php?dir=kingpin/utilities/linux_lowercase/&file=ccase.zip ccase]:< | </syntaxhighlight> | ||
<p>Search for every file that contains stricmp and not Q_stricmp and replace stricmp with Q_stricmp.<br />For example:< | <p>Or download the old [https://www.kingpin.info/download/index.php?dir=kingpin/server/unofficial/sdk/linux/old/&file=buildlinux_v0.zip buildlinux.]<br />The command line came from Xatrix [https://www.kingpin.info/download/index.php?dir=kingpin/server/official/sdk/&file=kingpinSDK-v121-navlib-linux-glibc-i386.zip kingpinSDK-v121-navlib-linux-glibc-i386.zip ]in makefile.<br />Quite interesting to look at to know how they compiled the linux version.<br />But a few things have changes in the mean time also for the compiler.</p> | ||
<p>Open g_items.c and search for:< | <hr> | ||
<p>First of all you need gcc. Open a terminal:</p> | |||
<syntaxhighlight lang="bash"> | |||
sudo apt-get install gcc | |||
</syntaxhighlight> | |||
<p>Now you all you need the libraries type next:</p> | |||
<syntaxhighlight lang="bash"> | |||
sudo apt-get install build-essential | |||
</syntaxhighlight> | |||
<p>This install the libraries<br />If you under a 64bit system you need also libc6-dev-i386:</p> | |||
<syntaxhighlight lang="bash"> | |||
sudo apt-get install libc6-dev-i386 | |||
</syntaxhighlight> | |||
<p>Width [https://www.kingpin.info/download/index.php?dir=kingpin/server/official/sdk/&file=kpsdk.zip kpsdk.zip] there some problems you need to fix.<br />Unzip the gamesrc to some folder.<br />Make everything lowercase in the folder with [https://www.kingpin.info/download/index.php?dir=kingpin/utilities/linux_lowercase/&file=ccase.zip ccase]:</p> | |||
<syntaxhighlight lang="bash"> | |||
chmod +x ccase | |||
./ccase -r * | |||
</syntaxhighlight> | |||
<p>Search for every file that contains stricmp and not Q_stricmp and replace stricmp with Q_stricmp.<br />For example: | |||
<syntaxhighlight lang="c"> | |||
&& (stricmp(self->enemy->client->pers.weapon->classname, "weapon_flamethrower") == 0)) | |||
</syntaxhighlight> | |||
Becomes: | |||
<syntaxhighlight lang="c"> | |||
&& (Q_stricmp(self->enemy->client->pers.weapon->classname, "weapon_flamethrower") == 0)) | |||
</syntaxhighlight> | |||
<p>Open g_items.c and search for:<p/> | |||
<syntaxhighlight lang="c"> | |||
static int jacket_armor_index; | |||
static int combat_armor_index; | |||
static int body_armor_index; | |||
static int power_screen_index; | |||
static int power_shield_index; | |||
</syntaxhighlight> | |||
<p>replace it with:</p> | |||
<syntaxhighlight lang="c"> | |||
int jacket_armor_index; | |||
int combat_armor_index; | |||
int body_armor_index; | |||
int power_screen_index; | |||
int power_shield_index; | |||
</syntaxhighlight> | |||
<p>Last bit to fix gcc version gcc 2.7.2.3 open game.h and search for:<p/> | |||
<syntaxhighlight lang="c"> | |||
trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, edict_t *passent, int contentmask); | |||
</syntaxhighlight> | |||
<p>replace it with:</p> | |||
<syntaxhighlight lang="c"> | |||
#if __linux__ | |||
// callee_pop_aggregate_return attribute allows modern GCC to be used | |||
trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, edict_t *passent, int contentmask) __attribute__((callee_pop_aggregate_return(0))); | |||
#else | |||
trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, edict_t *passent, int contentmask); | |||
#endif | |||
</syntaxhighlight> | |||
<p>Next open p_client.c and search for:</p> | |||
<syntaxhighlight lang="c"> | |||
trace_t PM_trace (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end); | |||
</syntaxhighlight> | |||
<p>replace it with:</p> | |||
<syntaxhighlight lang="c"> | |||
#if __linux__ | |||
trace_t __attribute__((callee_pop_aggregate_return(0))) PM_trace (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end) | |||
#else | |||
trace_t PM_trace (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end) | |||
#endif | |||
</syntaxhighlight> | |||
<p>Last one open q_shared.h and search for:<p/> | |||
<syntaxhighlight lang="c"> | |||
trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end); | |||
</syntaxhighlight> | |||
<p>replace it with:</p> | |||
<syntaxhighlight lang="c"> | |||
#if __linux__ | |||
// callee_pop_aggregate_return attribute allows modern GCC to be used | |||
trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end) __attribute__((callee_pop_aggregate_return(0))); | |||
#else | |||
trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end); | |||
#endif | |||
</syntaxhighlight> | |||
<p>Now for the linux navlib libaries get them from [https://www.kingpin.info/download/index.php?dir=kingpin/server/official/sdk/&file=kingpinSDK-v121-navlib-linux-glibc-i386.zip" kingpinSDK-v121-navlib-linux-glibc-i386.zip]</p> | <p>Now for the linux navlib libaries get them from [https://www.kingpin.info/download/index.php?dir=kingpin/server/official/sdk/&file=kingpinSDK-v121-navlib-linux-glibc-i386.zip" kingpinSDK-v121-navlib-linux-glibc-i386.zip]</p> | ||
<ul> | <ul> | ||
Line 18: | Line 94: | ||
</ul> | </ul> | ||
<p>and put them in your navlib folder.</p> | <p>and put them in your navlib folder.</p> | ||
<hr | <hr> | ||
<p>If this is all to much work or gives problems you can downloaded the fixed sdk from [https://www.kingpin.info/download/index.php?dir=kingpin/server/unofficial/sdk/linux/&file=Linux_SDK_121.zip here] with the makefile.</p> | <p>If this is all to much work or gives problems you can downloaded the fixed sdk from [https://www.kingpin.info/download/index.php?dir=kingpin/server/unofficial/sdk/linux/&file=Linux_SDK_121.zip here] with the makefile.</p> | ||
<p>Now you can compile sdk. There a few ways to compile the gamei386.so</p> | <p>Now you can compile sdk. There a few ways to compile the gamei386.so</p> | ||
<p>The best way:<br />Download this [https://www.kingpin.info/download/index.php?dir=kingpin/server/unofficial/sdk/linux/&file=makefile makefile] and run make in the terminale.<br />or Download this [https://www.kingpin.info/download/index.php?dir=kingpin/server/unofficial/sdk/linux/&file=buildlinux_v2.zip buildlinux] and make executable with:< | <p>The best way:<br />Download this [https://www.kingpin.info/download/index.php?dir=kingpin/server/unofficial/sdk/linux/&file=makefile makefile] and run make in the terminale.<br />or Download this [https://www.kingpin.info/download/index.php?dir=kingpin/server/unofficial/sdk/linux/&file=buildlinux_v2.zip buildlinux] and make executable with:</p> | ||
<syntaxhighlight lang="bash"> | |||
chmod +x buildlinux | |||
</syntaxhighlight> | |||
<p>Or change the [https://en.wikipedia.org/wiki/Chmod chmod] to your own settings so long it's executable.<br />or type in a terminal:</p> | |||
<syntaxhighlight lang="bash"> | |||
cc -m32 -Os -ffast-math -fno-finite-math-only -fPIC -shared -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,--no-undefined *.c navlib/*.o -lm -o gamei386.so | |||
</syntaxhighlight> | |||
<p>The second way is with this [https://www.kingpin.info/download/index.php?dir=kingpin/server/unofficial/sdk/linux/old/&file=buildlinux_v1.zip buildlinux] or this command line:</p> | |||
<syntaxhighlight lang="bash"> | |||
gcc *.c navlib/*.o -m32 -O2 -ffast-math -fPIC -shared -ffunction-sections -fdata-sections -Wl,--gc-sections -o gamei386.so | |||
</syntaxhighlight> |
Latest revision as of 00:12, 25 March 2025
You should know a little bit about linux before you can do this.
Kingpin in the past only compiled under gcc 2.7.2.3 compiler.
You mostly only get gcc 2.7.2.3 compiler under Redhat 5.2
Maybe that was the Linux version that Xatrix used.
But I'm going to use a debian linux system Xunbuntu (Based on Ubuntu but loads faster and easyr in a VirtualBox)
If you're using Redhat 5.2 for some reasson (not really recommend) the orginale command line to compile gamei386.so was:
gcc *.c *.o -s -m486 -O6 -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 -malign-jumps=2 -malign-functions=2 -fPIC -shared -o gamei386.so
Or download the old buildlinux.
The command line came from Xatrix kingpinSDK-v121-navlib-linux-glibc-i386.zip in makefile.
Quite interesting to look at to know how they compiled the linux version.
But a few things have changes in the mean time also for the compiler.
First of all you need gcc. Open a terminal:
sudo apt-get install gcc
Now you all you need the libraries type next:
sudo apt-get install build-essential
This install the libraries
If you under a 64bit system you need also libc6-dev-i386:
sudo apt-get install libc6-dev-i386
Width kpsdk.zip there some problems you need to fix.
Unzip the gamesrc to some folder.
Make everything lowercase in the folder with ccase:
chmod +x ccase
./ccase -r *
Search for every file that contains stricmp and not Q_stricmp and replace stricmp with Q_stricmp.
For example:
&& (stricmp(self->enemy->client->pers.weapon->classname, "weapon_flamethrower") == 0))
Becomes:
&& (Q_stricmp(self->enemy->client->pers.weapon->classname, "weapon_flamethrower") == 0))
Open g_items.c and search for:
static int jacket_armor_index;
static int combat_armor_index;
static int body_armor_index;
static int power_screen_index;
static int power_shield_index;
replace it with:
int jacket_armor_index;
int combat_armor_index;
int body_armor_index;
int power_screen_index;
int power_shield_index;
Last bit to fix gcc version gcc 2.7.2.3 open game.h and search for:
trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, edict_t *passent, int contentmask);
replace it with:
#if __linux__
// callee_pop_aggregate_return attribute allows modern GCC to be used
trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, edict_t *passent, int contentmask) __attribute__((callee_pop_aggregate_return(0)));
#else
trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, edict_t *passent, int contentmask);
#endif
Next open p_client.c and search for:
trace_t PM_trace (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end);
replace it with:
#if __linux__
trace_t __attribute__((callee_pop_aggregate_return(0))) PM_trace (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end)
#else
trace_t PM_trace (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end)
#endif
Last one open q_shared.h and search for:
trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end);
replace it with:
#if __linux__
// callee_pop_aggregate_return attribute allows modern GCC to be used
trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end) __attribute__((callee_pop_aggregate_return(0)));
#else
trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end);
#endif
Now for the linux navlib libaries get them from " kingpinSDK-v121-navlib-linux-glibc-i386.zip
- g_nav.o
- g_nav_cells.o
- g_nav_io.o
- g_nav_misc.o
and put them in your navlib folder.
If this is all to much work or gives problems you can downloaded the fixed sdk from here with the makefile.
Now you can compile sdk. There a few ways to compile the gamei386.so
The best way:
Download this makefile and run make in the terminale.
or Download this buildlinux and make executable with:
chmod +x buildlinux
Or change the chmod to your own settings so long it's executable.
or type in a terminal:
cc -m32 -Os -ffast-math -fno-finite-math-only -fPIC -shared -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,--no-undefined *.c navlib/*.o -lm -o gamei386.so
The second way is with this buildlinux or this command line:
gcc *.c navlib/*.o -m32 -O2 -ffast-math -fPIC -shared -ffunction-sections -fdata-sections -Wl,--gc-sections -o gamei386.so