zenorogue / hyperrogue

A SDL roguelike in a non-euclidean world
GNU General Public License v2.0
554 stars 66 forks source link

Building nil-rider using web recipe fail with linker error #334

Closed petterreinholdtsen closed 1 year ago

petterreinholdtsen commented 1 year ago

According to https://zenorogue.itch.io/nil-rider, the way to build nil-rider on a Debian derived Linux is to run mymake -O3 rogueviz/nilrider/nilrider.cpp. when I try this on a Debian Bookworm installation, after installing the dependencies mentioned in the README, I get this error:

/usr/bin/ld: mymake_files/O3/rogueviz_nilrider_nilrider.o: warning: relocation against `_ZN8rogueviz7cleanupE' in read-only section `.text._ZN8rogueviz7rv_hookIFvRN2hr5eLandEERFvS2_EEEvRNS1_7hooksetIT_EEiOT0_[_ZN8rogueviz7rv_hookIFvRN2hr5eLandEERFvS2_EEEvRNS1_7hooksetIT_EEiOT0_]'
/usr/bin/ld: mymake_files/O3/rogueviz_nilrider_nilrider.o: i funktionen ”nilrider::create_minitriangle()”:
nilrider.cpp:(.text+0x1e1d4): undefined reference to `hr::bricks::bricks'
/usr/bin/ld: nilrider.cpp:(.text+0x1e1db): undefined reference to `hr::bricks::bricks'
/usr/bin/ld: nilrider.cpp:(.text+0x1e1e4): undefined reference to `hr::bricks::bricks'
/usr/bin/ld: nilrider.cpp:(.text+0x1e1eb): undefined reference to `hr::bricks::build(bool)'
/usr/bin/ld: nilrider.cpp:(.text+0x1e1f8): undefined reference to `hr::bricks::bricks'
/usr/bin/ld: nilrider.cpp:(.text+0x1e203): undefined reference to `hr::bricks::bricks'
/usr/bin/ld: nilrider.cpp:(.text+0x1e353): undefined reference to `hr::bricks::bricks'
/usr/bin/ld: nilrider.cpp:(.text+0x1e35a): undefined reference to `hr::bricks::bricks'
/usr/bin/ld: mymake_files/O3/rogueviz_nilrider_nilrider.o: i funktionen ”nilrider::initialize()”:
nilrider.cpp:(.text+0x298df): undefined reference to `rogueviz::cleanup'
/usr/bin/ld: nilrider.cpp:(.text+0x298e6): undefined reference to `rogueviz::cleanup'
/usr/bin/ld: nilrider.cpp:(.text+0x298fa): undefined reference to `rogueviz::cleanup'
/usr/bin/ld: nilrider.cpp:(.text+0x29973): undefined reference to `rogueviz::cleanup'
/usr/bin/ld: mymake_files/O3/rogueviz_nilrider_nilrider.o: i funktionen ”hr::function_state<nilrider::celldemo::{lambda()#8}, void>::call() const”:
nilrider.cpp:(.text._ZNK2hr14function_stateIN8nilrider8celldemoMUlvE6_EvJEE4callEv[_ZNK2hr14function_stateIN8nilrider8celldemoMUlvE6_EvJEE4callEv]+0x213): undefined reference to `rogueviz::cleanup'
/usr/bin/ld: mymake_files/O3/rogueviz_nilrider_nilrider.o:nilrider.cpp:(.text._ZNK2hr14function_stateIN8nilrider8celldemoMUlvE6_EvJEE4callEv[_ZNK2hr14function_stateIN8nilrider8celldemoMUlvE6_EvJEE4callEv]+0x21a): more undefined references to `rogueviz::cleanup' follow
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
linking error!

Is there something missing in the build recipe, or is it outdated? Looking at rogueviz/nilrider/nilrider.cpp it seem to need a -DNILRIDER=1 define during build, which seem to be missing. Adding '#define NILRIDER 1' at the top of the file only gave other and more scary errors, so I suspect something more is needed too.

Are you able to help us get the nilrider program building on Linux?

zenorogue commented 1 year ago

It seems -rv is missing from that line, try: mymake -O3 -rv rogueviz/nilrider/nilrider.cpp

That should work.

-DNILRIDER=1 is not necessary, it is only for building an executable which contains only Nil Rider (that is, it starts Nil Rider when run without any options and does not include some features that are not used by Nil Rider). That would be built using

g++ -std=c++17 -DNILRIDER=1 rogueviz/nilrider/nilrider.cpp -c -o nilrider.o -O3 -I /usr/include/SDL/
g++ nilrider.o -o nilrider -lSDL -lGL -lSDL_gfx -lGLEW -lSDL_mixer savepng.cpp -lpng -lz -lSDL_ttf
petterreinholdtsen commented 1 year ago

Thank you. This worked better. I suspect the web comment 'run with commandline parameter "-nillrider"' got an unwanted double l, ie -nilrider .

zenorogue commented 1 year ago

Thanks, fixed this one too!