tmp64 / BugfixedHL-Rebased

Bugfixed and improved Half-Life
GNU General Public License v3.0
108 stars 22 forks source link

Linux compile for the client and server? #167

Closed N7P0L3ON closed 8 months ago

N7P0L3ON commented 1 year ago

Hello, I'm wondering if you have a guide on compiling the client and the server on Linux (Ubuntu or whatever)?

I'm trying to compile it on Ubuntu 22.02.2 and I'm hitting a brick wall :D I'm not using the GitHub workflows.

Any help will be appreciated.

tmp64 commented 1 year ago

The process is pretty similar to other CMake projects, only with the addition of a toolchain file (to build 32-bit binaries). I also set the generator to Ninja for faster builds in the commands below.

# Add `libssl1.1:i386 libssl-dev:i386 zlib1g-dev:i386` if you also need the auto-updater
sudo apt install cmake libc6:i386 ninja-build gcc-9-multilib g++-9-multilib
cd BHL-R
mkdir _build
cd _build
cmake .. -GNinja -DCMAKE_TOOLCHAIN_FILE="../cmake/ToolchainLinuxGCC.cmake"
ccmake . # Change settings if you want to
ninja
N7P0L3ON commented 1 year ago

Thanks this worked like a charm. :)

N7P0L3ON commented 1 year ago

I'm sorry for re-opening this issue. By the look of it the server and client compile under Linux with no errors, however upon testing them on the Linux box, the server just crashes... It crashes with the metamod and with no metamod (clean server)...

I checked the size of the resulting file it appears to be quite smaller, compared to the files you have provided in the builds for the client/server...

My compiles are:

hl.so - 2.2MB (2222568 bytes) client.so - 5.8MB (5809728 bytes)

I also checked the repository and git few tests, if I do a git clone of the repository the resulting size is 61.4 Mb (833 Files, 122 Folders) If I how ever do git clone --recursive of the repo the resulting size is 72.1 Mb (1580 Files, 187 Folders)

Now the question is... what is the correct way to clone the SDK?

I'm attaching the compile log for the SDK, system details for the Linux machine (Ubuntu 20.04.6 with details on everything installed) the server crash log (clean server) and server crash log with metamod/amx...

machine-details.txt server-crash-clean.txt server-crash-metamod.txt build-output.txt

I hope you can point me in the right direction towards what I'm missing...

N7P0L3ON commented 1 year ago

Quick update, I also did a fork of the repository, executed the build workflow on GitHub and the resulting .so files also crashed the server...

So something's wrong, the question is what...

Log ``` steam user is not set. Using anonymous user. /entrypoint.sh: line 22: ./steamcmd/steamcmd.sh: Permission denied :/home/container$ ./hlds_run -console -game ${HLDS_GAME} -port ${SERVER_PORT} -sport ${VAC_PORT} +map ${SRCDS_MAP} -strictportbind -norestart +maxplayers ${MAXPLAYERS} +ip ${SERVER_IP} ${CUSTOM_PARAMS} Enabling debug mode ./hlds_run: 125: test: Illegal number: unlimited Console initialized. Using breakpad crash handler Setting breakpad minidump AppID = 70 Forcing breakpad minidump interfaces to load Looking up breakpad interfaces from steamclient Calling BreakpadMiniDumpSystemInit Protocol version 48 Exe version 1.1.2.2/Stdio (valve) Exe build: 16:20:56 Sep 19 2022 (3082) STEAM Auth Server Server IP address 45.83.244.193:27015 Host_Error: Couldn't get DLL API from �:W ç�! FATAL ERROR (shutting down): Host_Error: Couldn't get DLL API from �:W ç�! Segmentation fault (core dumped) email debug.log to linux@valvesoftware.com Tue Apr 25 08:40:41 CEST 2023: Server Quit container@pterodactyl~ Server marked as offline... [Pterodactyl Daemon]: ---------- Detected server process in a crashed state! ---------- [Pterodactyl Daemon]: Exit code: 130 [Pterodactyl Daemon]: Out of memory: false [Pterodactyl Daemon]: Aborting automatic restart, last crash occurred less than 60 seconds ago. ```
andreiseverin commented 1 year ago

I can add, that the last automated generated builds for linux server don't work (from the red arrow up, none works for Linux) image

The error is the same as @N7P0L3ON mentioned in the post above

N7P0L3ON commented 1 year ago

I was about to guess the same, but I think Ubuntu 20.04 has different dependencies and different tools than the previously working 18.04... and by the look of it the working Linux server compiles were done on 18.04... So most likely the build workflow needs to be updated... @tmp64

The fun part is, I got the same error when compiling on Local VM running 20.04 and on a worker from GitHub running 20.04...

tmp64 commented 1 year ago

I also checked the repository and git few tests, if I do a git clone of the repository the resulting size is 61.4 Mb (833 Files, 122 Folders) If I how ever do git clone --recursive of the repo the resulting size is 72.1 Mb (1580 Files, 187 Folders)

Now the question is... what is the correct way to clone the SDK?

I keep forgetting about submodules. They are required. This will download them if you didn't use recursive clone.

git submodule init
git submodule update

I tested on a fresh install of Ubutnu 22.04 and HLDS. The only packages I installed were:

cmake libc6:i386 ninja-build gcc-9-multilib g++-9-multilib cmake-curses-gui steamcmd

After I copied the hl.so file I got errors like

LoadLibrary failed on /home/tmp64/projects/HLDS/./valve/dlls/hl.so: ./libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/tmp64/projects/HLDS/./valve/dlls/hl.so)
Host_Error: Couldn't get DLL API from /home/tmp64/projects/HLDS/./valve/dlls/hl.so!
FATAL ERROR (shutting down): Host_Error: Couldn't get DLL API from /home/tmp64/projects/HLDS/./valve/dlls/hl.so!
./hlds_linux: ./libgcc_s.so.1: version `GCC_7.0.0' not found (required by /lib/i386-linux-gnu/libstdc++.so.6)

I solved them by removing the outdated libraries that were installed with the server.

mv libstdc++.so.6 libstdc++.so.6.old
mv libgcc_s.so.1 libgcc_s.so.1.old

The server starts fine after all that was done.

I configured the project with -DCMAKE_BUILD_TYPE=RelWithDebInfo. Resulting hl.so is 15 MB (15177420 bytes) in size. The other difference is I used ToolchainLinuxGCC9.cmake toolchain (just like CI).

Release (when CMAKE_BUILD_TYPE is not set or set to Release) hl.so is 2.2 MB (2229996 bytes).

tmp64 commented 1 year ago

Run this command in the console from the server root. It will show which libraries are used.

LD_LIBRARY_PATH=. ldd valve/dlls/hl.so

Expected output:

tmp64@dev2204 ~/projects/HLDS $ LD_LIBRARY_PATH=. ldd valve/dlls/hl.so
        linux-gate.so.1 (0xf7ef9000)
        libstdc++.so.6 => /lib/i386-linux-gnu/libstdc++.so.6 (0xf7ade000)
        libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf79d6000)
        libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xf79af000)
        libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf777a000)
        /lib/ld-linux.so.2 (0xf7efb000)
N7P0L3ON commented 1 year ago

Thank you for checking this one. I will test the proposed solution and will revert back.

andreiseverin commented 1 year ago

I tried using that build and it keeps crashing for me:

Using anonymous user.
No appid set. Starting Server
:/home/container$ ./hlds_run -console -game ${HLDS_GAME} -port ${SERVER_PORT} -sport ${VAC_PORT} +map ${SRCDS_MAP} +ip ${SERVER_IP} -strictportbind -norestart +maxplayers 32 ${CUSTOM_PARAMS}
Console initialized.
Using breakpad crash handler
Setting breakpad minidump AppID = 70
Forcing breakpad minidump interfaces to load
Looking up breakpad interfaces from steamclient
Calling BreakpadMiniDumpSystemInit
Protocol version 48
Exe version 1.1.2.2/Stdio (valve)
Exe build: 16:20:56 Sep 19 2022 (3082)
STEAM Auth Server
Server IP address 212.87.213.185:27022
Host_Error: Couldn't get DLL API from   �!
FATAL ERROR (shutting down): Host_Error: Couldn't get DLL API from      �!
/entrypoint.sh: line 36:    14 Segmentation fault      (core dumped) ./hlds_run -console -game ${HLDS_GAME} -port ${SERVER_PORT} -sport ${VAC_PORT} +map ${SRCDS_MAP} +ip ${SERVER_IP} -strictportbind -norestart +maxplayers 32 ${CUSTOM_PARAMS}
container@pterodactyl~ Server marked as offline...
[Pterodactyl Daemon]: ---------- Detected server process in a crashed state! ----------
[Pterodactyl Daemon]: Exit code: 139
[Pterodactyl Daemon]: Out of memory: false
[Pterodactyl Daemon]: Aborting automatic restart, last crash occurred less than 60 seconds ago.

I had deleted before the 2 files in order to get BHL work and it runs the 1.9.1 present on releases but it won't run the last CI compilation. The attempt was made without metamod loaded.

The server ran on a Ubuntu 18.06 machine. When switched to Debian 11 it works like a charm. I think there are still some dependencies missing.

tmp64 commented 1 year ago

@andreiseverin Please, run this command on both Ubuntu 18.04 and Debian 11https://github.com/tmp64/BugfixedHL-Rebased/issues/167#issuecomment-1528733962

tmp64 commented 8 months ago

Closing for no response

andreiseverin commented 8 months ago

@tmp64 wanted to respond, but unfortunately I don't have root access to it. The server was hosted on a VPS and I can access it via a platform.

tmp64 commented 8 months ago

You can set up a local VM with Linux (e.g. in VirtualBox), compile BHL there and copy the .so file.