[dentonmod] Library search seems to be hardcoded
itaranto opened this issue · 11 comments
I've compiled dentonmod.so for Linux.
I want to be able to run the mod without putting dentonmod.so (or a symlink) in /usr/lib64/dhewm3/. The reason for this is I don't want messing around with the root filesystem.
Is there a way to change the directory where the game/mod searches for .so files?
You might be able to set LD_LIBRARY_PATH to hint the loader. (untested)
I did exactly that, it didn't worked.
LD_LIBRARY_PATH=/usr/local/share/dhewm3/dentonmod dhewm3 +set fs_basepath /usr/local/share/dhewm3
LD_LIBRARY_PATH
(just like the PATH
environment variable) should contain paths of directories that contain libraries, not the paths of libraries themselves. Specific library files can be specified by LD_PRELOAD
, not by LD_LIBRARY_PATH
.
/usr/local/share/dhewm3/dentonmod/
is a directory, the full path of the .so is /usr/local/share/dhewm3/dentonmod/dentonmod.so
.
Oh, initial version of your post contained LD_LIBRARY_PATH=/usr/local/share/dhewm3/dentonmod/dentonmod.so
and it's edited now.
Anyway, either LD_LIBRARY_PATH=/usr/local/share/dhewm3/dentonmod
(probably other directories should be added too) or LD_PRELOAD=/usr/local/share/dhewm3/dentonmod/dentonmod.so
. Did both of these ways fail for you?
Yep, my first post was incorrect so I edited it :)
I also tried LD_PRELOAD=/usr/local/share/dhewm3/dentonmod/dentonmod.so
, it didn't work.
Maybe the engine is calling dlopen explicitly to a "hard-coded" path?
strace
/ ltrace
tools can show you the parameters that were passed to dlopen. Did you try this way of debugging?
All this won't work anyway.
See https://github.com/dhewm/dhewm3/blob/04a50e1927ba662084fb9728bd8c45199057de9c/neo/framework/Common.cpp#L2573-L2607 - game DLLs are loaded with absolute paths, the default path being next to the dhewm3 executable, the fallback depending on the platform (BUILD_LIBDIR
is "/usr/local/lib/dhewm3"
by default on Linux).
When I find some time I'll take a closer look how this could be made less painful for mod development.
Yes that's what I observed, in my system (openSUSE) the base.so and d3xp.so files are placed under /usr/lib64/dhewm3/ so, the game tries to look for the mod's .so there.
I put the mod's .so under /usr/local/lib64/dhewm3/ and it worked.
WARNING: couldn't load mod-specific dentonmod.so, defaulting to base game's library
This behavior is correct since libraries should go in the lib-lib64 directories. As /usr/local/ is meant to be touched outside package managers this solution is fine for me.
Maybe I should update the README file to explain this, would that be OK?
It seems I made a mistake, I did my last test without dentonmod's game data.
After installing the game's data, the game crashes.
ERROR: Error: file Dentonmodv2final.pk4/script/doom_events.script, line 784: Unknown event 'setZoom'
I misinterpreted the log, dentonmod.so still not found:
WARNING: couldn't load mod-specific dentonmod.so, defaulting to base game's library!
loaded game library '/usr/lib64/dhewm3/base.so'.
So I ran strace to see where it was loooking for dentonmod.so:
86677 openat(AT_FDCWD, "/usr/bin/dentonmod.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
86678 openat(AT_FDCWD, "/usr/lib64/dhewm3/dentonmod.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
So, in conclusion:
Denton's mod works fine if dentonmod.so is under /usr/lib64/dhewm3/.
I think the distro maintainers built dhewm3 with CMAKE_INSTALL_PREFIX changed, so there's no way to workaround this.
I think I'll build dhewm3 from source now. Thanks for the support.