Operating system MacOS Sonoma 14.3.1, processor Apple M1. I faced the problem of running the compiled program. As it was written in the "title", I got this console output after run executable file:
> ./game
dyld[22230]: Library not loaded: @rpath/SDL2.framework/Versions/A/SDL2
Referenced from: <(random symbols, I don't think show it is a good idea)> /Users/(my username)/Downloads/game-prototype/game
Reason: no LC_RPATH's found
zsh: abort ./game
I have installed the SDL2 library with its add-ons both manually in the Library/Frameworks
folder and through homebrew (opt/homebrew/Cellar
), but the homebrew-version never worked. Perhaps the problem with the homebrew-version is due to the fact that I did not start this program and started to work only after I added export PATH=/opt/homebrew/bin:$PATH
in ~/.zprofile
. I can't really understand why it doesn't work.
The program was compiled by the following command:
clang main.c global.c on-create/*.c clock/*.c active/*.c -I/Library/Frameworks/SDL2.framework/Headers -F/Library/Frameworks -framework SDL2 -framework SDL2_image -framework SDL2_mixer -framework SDL2_ttf -o game
From a previously specified error, I opened the executable file (SDL2.framework/Versions/A/SDL2
) to check its functionality, and the console output was:
zsh: exec format error: /Library/Frameworks/SDL2.framework/Versions/A/SDL2
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
[Process completed]
Tell me, what should I do?
Adding -rpath /Library/Frameworks
to your clang invocation should fix the issue.
Alternatively, changing the install name of the framework, re-signing it and then recompiling your binary would also fix it:
install_name_tool -id /Library/Frameworks/SDL2.framework/Versions/A/SDL2 /Library/Frameworks/SDL2.framework/Versions/A/SDL2
codesign -s - -f /Library/Frameworks/SDL2.framework/Versions/A/SDL2
For a more in-depth explanation of install names, see this answer of mine.