serverplugin_empty under linux

Problem is compiled, but Source Linux dedicated server rejects to dynamically link it. I finally found the solution, and write it here for who share the trouble!

If you do not know what is, you must not waste your time to read this page! Just go back to your happy game!


Check what kind of libraries are linked to the so:
~/mymod/linux_sdk$ ldd -d 
undefined symbol: _Z12MathLib_Initfffibbbb (./
undefined symbol: _Z10Bot_RunAllv (./ => (0xffffe000) => /lib/tls/ (0xb7f51000) => /lib/tls/ (0xb7f4d000) => ./ (0xb7f1b000) => ./ (0xb7f06000) => /lib/tls/ (0xb7dce000)
/lib/ (0x80000000) => /lib/tls/ (0xb7dbb000)
Like above, the sample Makefile does not link enough object and dll files. As a result, there are two missing symbols which make dynamic-linking fails.

Fix1: _Z10Bot_RunAllv

This one is easy. Makefile.plugin misses to build and link serverplugin_bot.o. Fix it:
$(PLUGIN_OBJ_DIR)/serverplugin_convar.o \
$(PLUGIN_OBJ_DIR)/serverplugin_empty.o \
$(PLUGIN_OBJ_DIR)/serverplugin_bot.o \

Fix2: _Z12MathLib_Initfffibbbb (and _Z12AngleVectorsRK6QAngleP6Vector)

Only with Fix1, you still have missing symbols _Z12MathLib_Initfffibbbb and _Z12AngleVectorsRK6QAngleP6Vector. This is since the plugin still needs one more dll from the dedicated server in addition to and You can find the dll by:
nm --print-file-name .../bin/*so | grep MathLib_Initfffibbb
You will find bunch of .so dlls which define the symbol. I am not sure which one is the best, but I use Now modify Makefile (not Makefile.plugin):
# link flags for your mod, make sure to include any special libraries here
# LDFLAGS="-lm -ldl $(GAME_DIR)/bin/ $(GAME_DIR)/bin/"
LDFLAGS="-lm -ldl"
Of course I made a symbolic link of at the build directory and set LD_LIBRARY_PATH so that the linking goes successful.


Good luck!