chaosforgeorg / doomrl

D**m, the Roguelike
https://drl.chaosforge.org/
GNU General Public License v2.0
1.06k stars 130 forks source link

0.9.9.8 Linux build feedback and fixes #141

Open tung opened 1 month ago

tung commented 1 month ago

I'm on Debian 12 and I can confirm that the game compiles and runs, but only after a couple of source code tweaks.

Steps:

  1. Install dependencies: sudo install lua5.1 liblua5.1-0-dev fp-compiler fp-units-base fp-units-fcl fp-units-misc
  2. Also install SDL 2 libs, if you don't already have them: sudo install libsdl2-2.0-0 libsdl2-image-2.0-0 libsdl2-mixer-2.0-0 libsdl2-ttf-2.0-0
  3. Get the DRL and FPC Valkyrie source code and put their directories are next to each other.
  4. Get the game download from https://drl.chaosforge.org and extract the files from mp3, music, wav and wavhq into the matching sub-directories in DRL's bin directory.
  5. In the DRL directory, mkdir tmp otherwise compilation fails with the following message:
vutil.pas(800,1) Error: Can't create object file: tmp/vutil.o (error code: 2)
vutil.pas(800,1) Fatal: Can't create object tmp/vutil.o
  1. In the FPC Valkyrie code, comment out references to IMG_LoadWEBPAnimation_RW; Debian 12's SDL2_Image doesn't seem to have it and DRL doesn't need it.
diff --git a/libs/vsdl2imagelibrary.pas b/libs/vsdl2imagelibrary.pas
index 0808885..fa497f5 100644
--- a/libs/vsdl2imagelibrary.pas
+++ b/libs/vsdl2imagelibrary.pas
@@ -103,7 +103,7 @@ var
   IMG_LoadAnimationTyped_RW       : function (src: PSDL_RWops; freesrc: Integer; const _type: PChar): PIMG_Animation; cdecl;
   IMG_FreeAnimation               : procedure (anim: PIMG_Animation); cdecl;
   IMG_LoadGIFAnimation_RW         : function (src: PSDL_RWops): PIMG_Animation; cdecl;
-  IMG_LoadWEBPAnimation_RW        : function (src: PSDL_RWops): PIMG_Animation; cdecl;
+  {IMG_LoadWEBPAnimation_RW        : function (src: PSDL_RWops): PIMG_Animation; cdecl;}

 var
   SDL2_image : TLibrary = nil;
@@ -184,7 +184,7 @@ begin
   Pointer(IMG_LoadAnimationTyped_RW) := GetSymbol('IMG_LoadAnimationTyped_RW');
   Pointer(IMG_FreeAnimation) := GetSymbol('IMG_FreeAnimation');
   Pointer(IMG_LoadGIFAnimation_RW) := GetSymbol('IMG_LoadGIFAnimation_RW');
-  Pointer(IMG_LoadWEBPAnimation_RW) := GetSymbol('IMG_LoadWEBPAnimation_RW');
+  {Pointer(IMG_LoadWEBPAnimation_RW) := GetSymbol('IMG_LoadWEBPAnimation_RW');}

   Exit( True );
 end;
  1. Run the build: lua5.1 makefile.lua
  2. Run the game: cd bin and ./drl

In this state, the game makes a window but crashes immediately; seems like there's a problem with FLayers being nil in TDoomIO.Destroy in src/doomio.pas, so patch it like this and build it again:

diff --git a/src/doomio.pas b/src/doomio.pas
index c9a5465..4e1d945 100644
--- a/src/doomio.pas
+++ b/src/doomio.pas
@@ -541,8 +541,9 @@ begin
   FreeAndNil( FOldASCII );
   FreeAndNil( FNewASCII );

-  for iLayer in FLayers do
-    iLayer.Free;
+  if FLayers <> nil then
+    for iLayer in FLayers do
+      iLayer.Free;
   FreeAndNil( FLayers );
   IO := nil;
   inherited Destroy;

At this point the game should launch and run successfully.

I think you can type just sudo lua5.1 liblua5.1-0-dev fpc instead of all the fp-whatever stuff at the first step, but it'll install a lot more than what you strictly need to build the game.

epyon commented 1 month ago

Thanks! I'll integrate it to Monday's patch and try to build official Linux builds (I failed to notice a few things you mentioned here and was running against the clock at release day).

Edit: Also, long time no see :)

tung commented 1 month ago

No worries, I understand how busy release days can be; just thought you might appreciate the testing.

dderevjanik commented 1 month ago

Do you think it would be possible to use Docker in order to avoid installing dependencies?

@epyon do you have any plan to release on mac with ARM?

epyon commented 1 month ago

If someone supplies a mac build/patch, I'd gladly integrate it and put it up as official. Myself I no longer have access to any mac's at all :/

dderevjanik commented 1 month ago

Thank you for your response. Setting up the development environment on my Mac has been quite challenging, which is why I was asking about using Docker.

epyon commented 3 weeks ago

Linux binaries are up! Please test them if all is ok, and I'll close this issue!

dderevjanik commented 3 weeks ago

Do you have any plans to release OSX binaries as well?

Additionally, I have created a Dockerfile for compiling DRL, but I'm not sure if anything is missing. Cannot find drl in doomrl/bin. What do you think @tung ?

# Use an official Ubuntu as a base image
FROM ubuntu:22.04

WORKDIR /chaosforgeorg
# Install necessary packages
RUN apt update
RUN apt install -y \
    git \
    curl \
    unzip
RUN apt install -y \
    lua5.1 \
    liblua5.1-0-dev \
    fp-compiler \
    fp-units-base \
    fp-units-fcl \
    fp-units-misc
RUN apt install -y \
    libsdl2-2.0-0 \
    libsdl2-image-2.0-0 \
    libsdl2-mixer-2.0-0 \
    libsdl2-ttf-2.0-0
RUN git clone https://github.com/chaosforgeorg/doomrl.git \
    && git clone https://github.com/chaosforgeorg/fpcvalkyrie.git
RUN curl -L -o drl-win-0998.zip https://drl.chaosforge.org/file_download/41/drl-win-0998.zip
RUN unzip drl-win-0998.zip \
    && cp drl-win-0998/mp3/* doomrl/bin/mp3 \
    && cp drl-win-0998/wavhq/* doomrl/bin/wavhq
ENV HOME=/home
RUN cd doomrl && lua5.1 ./makefile.lua
tung commented 3 weeks ago

The Linux binaries on the website need glibc 2.38, which means they're built for either Ubuntu 23.10/24.04 or Debian unstable/testing, and I only have a Debian 12 stable setup here, so someone else will have to test them. I can at least confirm that the current versions of DRL and FPC Valkyrie compile with no changes, except for having to make the "tmp" directory before building.

@dderevjanik Make the "tmp" directory before building; it might also be a good idea to check out specific tags/commits of the drl and fpcvalkyrie repos if you want it to be reproducible.

dderevjanik commented 3 weeks ago

Thanks! I tried it with mkdir tmp, but another error occurs. Have no idea what's going on..

#13 [10/10] RUN cd doomrl && mkdir tmp && echo 'done' && lua5.1 ./makefile.lua
#13 13.49 done
#13 17.83 Free Pascal Compiler version 3.2.2+dfsg-9ubuntu1 [2022/04/11] for aarch64
#13 17.83 Copyright (c) 1993-2021 by Florian Klaempfl and others
#13 20.53 vgenerics.pas(183,26) Hint: Parameter "aItem" not used
#13 20.53 vgenerics.pas(271,26) Hint: Parameter "aItem" not used
#13 21.61 vluaext.pas(484,49) Hint: Local variable "lnumber" does not seem to be initialized
#13 32.13 vfmod2library.pas(334,3) Error: Identifier not found "Set8087CW"
#13 32.13 vfmod2library.pas(706,5) Error: Identifier not found "Set8087CW"
#13 32.13 vfmod2library.pas(711) Fatal: There were 2 errors compiling module, stopping
#13 32.13 Fatal: Compilation aborted
#13 32.13 Error: /usr/bin/ppca64 returned an error exitcode
#13 32.14 Autodetected OS - LINUX
#13 DONE 32.4s
draeath commented 3 weeks ago

This doesn't want to run on OpenSUSE Tumbleweed:

draeath@ginnungagap:/opt/draeath/drl-linux-0998> ldd drl
./drl: /lib64/libncursesw.so.6: version `NCURSESW6_5.6.20061217' not found (required by ./drl)
./drl: /lib64/libncursesw.so.6: version `NCURSESW6_5.3.20021019' not found (required by ./drl)
./drl: /lib64/libncursesw.so.6: version `NCURSESW6_5.1.20000708' not found (required by ./drl)
        linux-vdso.so.1 (0x00007ffc32f6d000)
        libm.so.6 => /lib64/libm.so.6 (0x00007ff515cdc000)
        libX11.so.6 => /lib64/libX11.so.6 (0x00007ff515b95000)
        libncursesw.so.6 => /lib64/libncursesw.so.6 (0x00007ff515b55000)
        libtinfo.so.6 => /lib64/libtinfo.so.6 (0x00007ff515b18000)
        libc.so.6 => /lib64/libc.so.6 (0x00007ff515800000)
        /lib64/ld-linux-x86-64.so.2 (0x00007ff515dea000)
        libxcb.so.1 => /lib64/libxcb.so.1 (0x00007ff515aec000)
        libXau.so.6 => /lib64/libXau.so.6 (0x00007ff515ae7000)
draeath@ginnungagap:~> rpm -qa | grep libncurses6
libncurses6-6.5.20240817-43.1.x86_64
libncurses6-32bit-6.5.20240817-43.1.x86_64

I tried (and completely failed) to build it myself, the furthest I could get was Lazarus whining about undefined symbols (I didn't keep the details, but I could recreate my efforts if you want them).

jason-mehmel commented 2 weeks ago

The Linux binaries on the website need glibc 2.38, which means they're built for either Ubuntu 23.10/24.04 or Debian unstable/testing, and I only have a Debian 12 stable setup here, so someone else will have to test them. I can at least confirm that the current versions of DRL and FPC Valkyrie compile with no changes, except for having to make the "tmp" directory before building.

@dderevjanik Make the "tmp" directory before building; it might also be a good idea to check out specific tags/commits of the drl and fpcvalkyrie repos if you want it to be reproducible.

I had the same problem re: glibc 2.38 when trying to run the version for download on the website. Haven't tried to compile it myself yet.

If I tried to compile it, would that then end up using glibc 2.36 (which is in Stable) or is that dependency based on the calls inside the code?

dderevjanik commented 1 week ago

@jason-mehmel thanks!

I was able to fix that problem by installing libx11-dev and running ldconfig before compiling drl. There was another issue, that I used drl.wad from Windows build instead of Linux one (how to build drl.wad @epyon ?) .

Now, I'm facing another issue

Abnormal program termination!

Reason : Can't load library "libSDL2_image-2.0.so.0": libSDL2_image-2.0.so.0: cannot open shared object file: No such file or directory

If this reason doesn't seem your fault, please submit a bug report at
http://forum.chaosforge.org/, be sure to include the last entries in
your error.log that will get created once you hit Enter.

Any ideas how to fix it?

If anyone is interested, here's my latest Dockerfile with compile script https://gist.github.com/dderevjanik/1be7840284b58af65a32ce2a7d15a840

@epyon Is it possible to build Windows/Mac binaries using Linux?