[BUG] Gmod.NET is not working on Ubuntu 18.04 and older
Bug description
Garry's Mod Dedicated Server is not able to load Gmod.NET on Ubuntu 18.04 (newer versions work just fine).
Error message:
[ERROR] lua/autorun/start.lua:1: Couldn't load module library!
1. require - [C]:-1
2. unknown - lua/autorun/start.lua:1
Can be reproduced with the following Dockerfile:
FROM ubuntu:18.04
WORKDIR /steam
RUN apt-get update
RUN apt-get install -y lib32gcc1
RUN apt-get install -y curl
RUN curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -
RUN ./steamcmd.sh +login anonymous +force_install_dir /gmod "+app_update 4020 -beta x86-64 validate" +quit
WORKDIR /gmod/garrysmod/lua/bin
RUN curl -sqL "https://github.com/GmodNET/GmodDotNet/releases/download/0.7.1/gmod-dot-net-linux.0.7.1.tar.gz" | tar zxvf -
COPY start.lua /gmod/garrysmod/lua/autorun
RUN apt-get install -y libc6 libgcc1 libgssapi-krb5-2 libicu60 libssl1.1 libstdc++6 zlib1g
WORKDIR /gmod
ENTRYPOINT ./srcds_run_x64 -game garrysmod -systemtest -condebug +sv_hibernate_think 1
Posible cause
Since we are building C++ code of the Gmod.NET on Ubuntu 20.04, it is likely that we are implicitly linking to something (like newer libc version) which is not available on Ubuntu 18.04.
Can we update some library or link to library without version in name?
The problem is indeed an older version of libc and libstdc++. Here is an Ubuntu 18.04 dockerfile with a fix:
FROM ubuntu:18.04
WORKDIR /steam
RUN apt-get update
RUN apt-get install -y lib32gcc1
RUN apt-get install -y curl
RUN curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -
RUN ./steamcmd.sh +login anonymous +force_install_dir /gmod "+app_update 4020 -beta x86-64 validate" +quit
WORKDIR /gmod/garrysmod/lua/bin
RUN curl -sqL "https://github.com/GmodNET/GmodDotNet/releases/download/0.7.1/gmod-dot-net-linux.0.7.1.tar.gz" | tar zxvf -
COPY start.lua /gmod/garrysmod/lua/autorun
RUN apt-get install -y libc6 libgcc1 libgssapi-krb5-2 libicu60 libssl1.1 libstdc++6 zlib1g
RUN apt-get install -y software-properties-common
RUN add-apt-repository ppa:ubuntu-toolchain-r/test
RUN apt-get update
RUN apt-get install -y gcc-9 g++-9
WORKDIR /gmod
ENTRYPOINT ./srcds_run_x64 -game garrysmod -systemtest -condebug +sv_hibernate_think 1
TLDR if we install a gcc version 9 from experimental channel on Ubuntu 18.04, it brings newer libc and libstdc++ versions to system, and Gmod.NET works just fine.
Since we are using C++ 17 features in our bootstrapping module, we can't downgrade our build pipeline to Ubuntu 18.04 and GCC 7.
We need to create a docs article which will state that Linux distribution should be equipped with GCC 9 and newer (like Ubuntu 20.04) and if upgrade of the OS is not available, install newer version of GCC manually.
Hello guys, this is quite a common issue with Gmod modules. For my modules I build using a manylinux2014 Docker container which uses the ancient CentOS 7, and works even on the shittiest of Russian hosts.
Here is the github actions yml, hopefully it will help you
https://github.com/WilliamVenner/gmsv_workshop/blob/master/.github/workflows/build.yml