Posts Tagged "server"

Half Life 2 Linux Server Builds

So, recently I was playing around with building a server for a Half Life 2 modification using Valve’s instructions on their wiki. The instructions all seem quite simple, you take the VC++ project file, a makefile that you customise slightly with some locations of things certain libraries (like the xerces ones) and then some libraries from the official Linux dedicated server.

All sensible enough so far, until you find out that the only way to get the libraries that it needs from the server is to download the whole server and install that using their application for this (which takes two passes at the same command to do that for some reason). This pulls about 780MB of stuff down onto the machine, including all of the HL2MP maps, textures, models and sounds (apparently it needs some of these in case you want to run a pure server without people having their own custom sounds and whatnot). All in all the libraries that I wanted were no more than 35MB of this, so it was a little bit frustrating.

You then get to the build process, which first compiles a util (vcpm) to read the vc++ project file and use that to make a makefile for the mod itself. This is all well and good and all done in one fell swoop with a simple ‘make’. Unfortunately if, for some reason, you want to do a clean build of the mod – ‘make clean’ won’t help you. That just cleans up vcpm, leaving the server objects there waiting for you to do it manually.

The whole compile process was also very slow, although that could be my machine (it is 4-5 years old now) and produces one hell of a binary. I’m pretty sure that this is down to it linking statically with a lot of libraries, including some of the c/c++ ones, although I have yet to verify this or follow the guide on the wiki that suggests you can cut 5MB off the binary with some magic. Perhaps in future builds I’ll look at getting that done, but for now I’m just happy that it compiled.

Having done this with gcc-4.1 (4.2 just plain doesn’t work, but then isn’t claimed to on the wiki) I found that crashes occured for other people, hardly good. So I dug out gcc-3.4 and had a bash with that, only to find that errors were soon the scourge of my life again, some of them seemingly in the Valve code – great. Fortunately a bit of digging around in the documentation turns out that it’s a known thing where gcc-3.4 won’t inline functions unless you give it a -O option. This fixed it was clean sailing and I had a nice compiled version.

Unfortunately this version also segfaulted, so it was off to the debug build and to see what was going on with it. This proved rather useless, as the engine produces a stack trace without any symbols (even after the mod is compiled with them) so I’ll need to have a rummage around what’s going on at some stage, probably something to do with my system configuration compared to that of the server. Nothing is ever simple eh?