Compiling with Linux

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;
and remove the static. So it says: int ????_armor_index; ???? with the correct name.

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


FREDZ | Thursday 09 June 2016 - 00:17
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • email
  • Facebook
  • Google
  • PrintFriendly