Marine Bot banner

Compiling Marine Bot on Linux

Deciding to compile own library

If you are skilled Linux user then this guide isn't for you. You already have the knowledge to build Marine Bot library on your own. This guide is meant for people with very little or basically no knowledge of Linux. I'm one of you :) ... because whenever I need to do something on Linux, I'm googling a lot. Then it is a trial and error till I manage what I needed to do. Now you may ask what is the reason to compile own Marine Bot .so library if there is always one available for download for each release. There may be several various reasons. More or less important for each of you. But there is one that will probably force you to do so. And that is compatibility. Marine Bot .so library, that is available for download with each release, is usually compiled on the most recent Ubuntu Desktop LTS (Long Term Support). But if you are running different Linux distribution or older Ubuntu, then you may get an error when you try to load this Marine Bot library on your server. There is an example of such error at the end of this guide. You might be able to deal with such error by updating the system libraries on your server if you have the rights and knowledge to do so, but you may then get errors in other software you are using there. Therefore Marine Bot always comes with the source code for each release so that you can build a library that is compatible with the system you are using on your server. So let's get to it.

The preparation

To build own Marine Bot .so library we will obviously need to download Marine Bot source code. And then Half-Life SDK. There are a few different versions of the HLSDK available on internet. You can read more about it in "mb_readme.txt" file that is part of Marine Bot source code package since version 0.94b. I'm always using the original v2.3 to compile all Marine Bot libraries so I'll use it even in this guide. This 2.3 version of HLSDK is also available as a zip archive on Marine Bot homepage. Head to the "Files" section and then scroll down to the "Miscellaneous files". Having to deal with the original exe installer may be a bit inconvenient so with the help of Wine in Ubuntu I've installed it, then zipped the content of it and uploaded it to Marine Bot homepage. I believe it is easier to get it this way. When we have both packages with source code downloaded and ready, we can start.
the two source code packages are ready

First we will move Marine Bot source code into HLSDK. The exact folder, where Marine Bot source code must be placed, differs based on which HLSDK version you decided to use. Please consult the "mb_readme.txt" file for the details related to various versions of HLSDK. I'm using default HLSDK v2.3 so Marine Bot source code must be placed into "Multiplayer Source".
MB source code inside the HLSDK

I'll repeat that I'm using Ubuntu Desktop in version 22.04 LTS here. So the rest of this guide is specific to this Linux distribution. It is a fresh installation. Nothing has been installed to it yet. I've purposely made a fresh installation so that I can show you all steps that will get you from downloading the source code to own working Marine Bot .so library. Okay so once the folder with Marine Bot source code is correctly placed, open it. You should see something like this. I've erased all files related to MS Visual Studio for Windows. Because on Linux you need just the .cpp, .h and the makefile files to build the library.
inside the folder with MB source code

The compilation

Now right-click on free space inside the folder and select the "Open in Terminal" option from the menu. A new terminal window will pop-up. To build the library you need to type make command. But as you can see a freshly installed Ubuntu doesn't have it. So we will have to install it by typing sudo apt install make. Make sure you remember your password, because you'll be asked to confirm these commands using the password.
the terminal window just opened

Now that we have installed "make" we will try to build the library again. Well okay g++ isn't known to fresh Ubuntu. That means that GCC (GNU Compiler Collection) isn't part of Ubuntu Desktop installation either. We will have to install it too. This time we didn't get any help right away like in previous case. But Google knows almost everything, right? ;) To install g++ that is used inside "makefile" we will have to use this command sudo apt install build-essential. Type the password again and then confirm that you want to continue. Notice the Suggested packages. The "g++-multilib" and "gcc-multilib" are listed there. This is actually a nice hint. By the way I have a feeling I read somewhere that "make" is probably part of "build-essential". So previous step could have been skipped. But like I said I'm no Linux guru so I'm going the trial and error way :).
installing build-essential

The "makefile" is using the -m32 build option in order to build a 32-bit Marine Bot library. However we are running a 64-bit system, Ubuntu 22.04 LTS is 64-bit OS and the CPU in this ancient laptop also uses 64-bit architecture (instruction set). So if you tried to build Marine Bot now you would get an error again. It wouldn't be the same error as before of course, but most probably an error pointing to a missing library or unknown header file. Luckily there is this Multilib. It can deal with the 32-bit vs. 64-bit mismatch. In other words it allows you to compile and run a 32-bit application on a 64-bit system. If you want to know all the details just google it. All we need to know now is that we will have to install it. To do so just type this command sudo apt install gcc-multilib g++-multilib and confirm that you want to continue.
installing multilib

Once everything is installed, we can finally build Marine Bot library. So type make command and wait till the compilation and linking is done.
finally building Marine Bot library

Now you can close the terminal window, because we are done. We have our own Marine Bot .so library inside the folder with the source code. In this guide we have built Marine Bot for Firearms library. If you used source code for the Day of Defeat port of Marine Bot, you'd get "marinebot.so" (without the underscore character). But the final name doesn't really matter. You can rename the library at will. Then move it to Dedicated Server folder and start the server.
Marine Bot library inside the folder with source code

Examples of a compatibility error for Marine Bot library when trying to start a Dedicated Server or run a local client game

Following two screenshots will show you the reason why you may need to build your own Marine Bot .so library. Here I'm trying to use the library I've built while creating this guide. The library was built on Ubuntu 22.04 LTS, but I've rebooted the laptop and started older Ubuntu 20.04 LTS where I have the old test Dedicated Server. First I'm trying to start the server with Metamod. This is what you want to do for a public server. Metamod allows you to load Adminmod and/or other plugins that are useful on public server. As you can see the server failed and the error message doesn't say much. Actually it's a pretty confusing error message, because the versions do match. Both do return a value 140.
compatibility error when starting the server with metamod

Let's try to start the server with just Marine Bot (without Metamod loader). Now we got something. We can google the "libc.so.6: version 'GLIBC_2.34' not found" error. Conclusion is Ubuntu 20.04 LTS has only version 2.31. So it's either upgrading to Ubuntu 22.04 LTS or using older Marine Bot that was built on older Ubuntu or if you have access to source code then build it on your own.
compatibility error when starting the server with just Marine Bot

Unlike the mod Firearms the Day of Defeat 1.3 can be played on Linux natively. I mean not running a Dedicated Server, but standard client gaming on your Linux PC. So you can have these Linux compatibility issues there too. Say that you start the DoD on your Steam library to get to the game main menu. Where you click on the "New Game", but then nothing happens and you stay in the main menu. This means there must have been some error that prevented starting local game server and connecting you to it. Unlike on Dedicated Server you don't see the console by default. However if you press the "tilde" key in this main menu the console will open. And you will be able to see the error message/s that way. The following screenshot shows the very same error as we have above. Marine Bot for Day of Defeat 1.3 library was compiled on Ubuntu 22.04 LTS, but now I'm trying to run it on older Ubuntu 20.04 LTS with old system libraries that return this error then.

compatibility error when starting client game of Day of Defeat 1.3 with Marine Bot

Do you want to know more?

Following link will get you to Marine Bot homepage where you can find more guides like this one.

by Frank McNeil 2005-2024


end of file