I want to make a command-line tool with a few bundled frameworks that it needs (SDL and related libs). I have Xcode set to "Embed & Sign" these frameworks, and this results in them being copied to the build folder next to the executable. The resulting executable runs correctly within Xcode.
But when I try to run the same executable on the command line, it fails with:
dyld: Library not loaded: @rpath/SDL2.framework/Versions/A/SDL2
Referenced from: /Users/jstrout/Data/CPP-dev/soda/Build/Products/Debug/./soda
Reason: image not found
zsh: abort ./soda
even though, relative to the current (and executable) directory, the image is indeed at SDL2.framework/Versions/A/SDL2. The problem appears to be that rpath is not set correctly. All my searching says that I should find an LC_RPATH command in the output of otool -l
on my executable, but in fact there is no LC_RPATH command in there at all (despite several LC_LOAD_DYLIB commands that reference @rpath).
So. What must I do in Xcode to get it the linker to emit the proper LC_RPATH command? Or, if I'm barking up the wrong tree entirely: how do I get my command-line executable to reference frameworks that are sitting right next to it?