Doubt with GZDoom compiling process

Need help running G/Q/ZDoom/ECWolf/Zandronum/3DGE? Did your computer break? Ask here.

Moderator: GZDoom Developers

sacarias
Posts: 16
Joined: Wed Oct 02, 2019 9:39 am

Doubt with GZDoom compiling process

Post by sacarias »

Built GZDoom on Debian 11 on build directory $HOME/gzdoom_build, using cmake flags -DZMUSIC_LIBRARIES=$HOME/zmusic_build/source/libzmusic.so -DZMUSIC_INCLUDE_DIR=$HOME/zmusic_build/include

This works, albeit it's built exactly with runpath (or rpath, not sure...) /home/<user>/zmusic_build/source, as shown by command:

Code: Select all

readelf -d gzdoom_build/gzdoom | grep -i runpath
Which causes GZDoom to fail to run if zmusic_build directory is moved anywhere else, giving error

Code: Select all

error while loading shared libraries: libzmusic.so.1: cannot open shared object file: No such file or directory
I tried a possible solution: copy zmusic_build directory inside gzdoom_build, symlink libzmusic.so.1 directly inside gzdoom_build, and modify the gzdoom binary's rpath/runpath to $ORIGIN, by using "patchelf" command, which makes binary read all its needed libraries from binary's current location.
It seemingly worked. Now GZDoom can be run even if moving entire gzdoom_build directory anywhere.

Now what I wanted to try asking is, can't this be done somehow since building time? Don't know, with some cmake options or the like... to make binary read all needed libraries from its current location, without the patchelf step.

Thanks for your help.
sacarias
Posts: 16
Joined: Wed Oct 02, 2019 9:39 am

Re: Doubt with GZDoom compiling process

Post by sacarias »

Ok, after a forum search I found this:
viewtopic.php?f=12&t=60749&start=45#p1058751
viewtopic.php?f=341&t=69606#p1162707
Now I need to search how to do "link executable with -Wl,-rpath='$ORIGIN'"...
And what's the -Wl option for?
User avatar
KynikossDragonn
Posts: 202
Joined: Sat Dec 12, 2020 10:59 am
Twitch ID: kynikossdragonn
Github ID: KynikossDragonn
Graphics Processor: Intel (Modern GZDoom)
Location: Independence, KS, USA

Re: Doubt with GZDoom compiling process

Post by KynikossDragonn »

You can just add a CMAKE_INSTALL_RPATH with it set to $ORIGIN, then when you run the install target it will automatically set RPATH to $ORIGIN during the stripping process.

If you're confused this is where I looked it up: https://gitlab.kitware.com/cmake/commun ... H-handling

Just make sure you set the install prefix to something other than /usr/local of course. I usually set it to a "buildinstall" directory inside of the "build" directory I'm running the entire build process on in the cloned repository.

You can then copy the resulting binary anywhere and it should find the ZMusic library in the same location as the binary is executed from, providing you place it there.

It might be easier to use the CMake GUI tool, you can manually insert your own options in it even if they're not present in the CMakeLists.

Return to “Technical Issues”