Doubt with GZDoom compiling process

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

Moderator: GZDoom Developers

Doubt with GZDoom compiling process

Postby sacarias » Mon Dec 06, 2021 5:01 pm

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 allExpand view
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 allExpand view
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
 
Joined: 02 Oct 2019

Re: Doubt with GZDoom compiling process

Postby sacarias » Wed Dec 29, 2021 12:35 am

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?
sacarias
 
Joined: 02 Oct 2019

Re: Doubt with GZDoom compiling process

Postby KynikossDragonn » Wed Dec 29, 2021 9:31 am

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.
User avatar
KynikossDragonn
『霧雨魔理沙のペットドラゴン』
 
Joined: 12 Dec 2020
Location: Independence, KS, USA
Twitch ID: kynikossdragonn
Github ID: KynikossDragonn
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: Intel (Modern GZDoom)


Return to Technical Issues

Who is online

Users browsing this forum: No registered users and 1 guest