nillerusr / source-engine

Modified source engine (2017) developed by valve and leaked in 2020. Not for commercial purporses
Other
1.13k stars 173 forks source link

[macOS] Hard-coded locations for dylibs instead of @rpath #219

Open shinra-electric opened 1 year ago

shinra-electric commented 1 year ago

Issue: When building on macOS (ARM) you need to keep the build folder or else no game will run.

if you run otool -L on any of the output dylibs you can see that they are hard-coded to be located in the build directory. This means the build directory needs to be still installed when trying to run a game.

They should be using @rpath or @executable_path instead.

This example is looking at liblauncher.dylib Terminal Saved Output.txt

(System files shouldn't be affected)

shinra-electric commented 1 year ago

I just saw PR #176 that should fix this.

shinra-electric commented 3 months ago

It looks like #176 was closed, so this issue is still outstanding

shinra-electric commented 2 months ago

I have successfully worked around this issue using install_name_tool using the following:


# Fix paths for liblauncher.dylib
codesign --remove-signature ${GAME_TITLE}.app/Contents/MacOS/bin/liblauncher.dylib

install_name_tool -change $(brew --prefix sdl2)/lib/$SDL_FILENAME @loader_path/$SDL_FILENAME ${GAME_TITLE}.app/Contents/MacOS/bin/liblauncher.dylib

install_name_tool -change ${SCRIPT_DIR}/source-engine/build/togl/libtogl.dylib @loader_path/libtogl.dylib ${GAME_TITLE}.app/Contents/MacOS/bin/liblauncher.dylib

install_name_tool -change ${SCRIPT_DIR}/source-engine/build/vstdlib/libvstdlib.dylib @loader_path/libvstdlib.dylib ${GAME_TITLE}.app/Contents/MacOS/bin/liblauncher.dylib

install_name_tool -change ${SCRIPT_DIR}/source-engine/build/tier0/libtier0.dylib @loader_path/libtier0.dylib ${GAME_TITLE}.app/Contents/MacOS/bin/liblauncher.dylib

install_name_tool -change ${SCRIPT_DIR}/source-engine/build/stub_steam/libsteam_api.dylib @loader_path/libsteam_api.dylib ${GAME_TITLE}.app/Contents/MacOS/bin/liblauncher.dylib

Here is the full build script for reference: source_engine_build.sh.zip