-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Information on how to get SDL2 working on OSX #175
Comments
I've just spend about 2 hours troubleshooting this issue... Could it be linked somewhere from README file? |
@golergka I opened up an issue on the sdl2_game_window repo. PistonDevelopers/sdl2_window#72 |
👍 Let me know if you want me to raise a PR. |
@subhashb Please do. |
@bvssvni Here goes: PistonDevelopers/piston-examples#92 |
On ubuntu 14.10:
|
worked fine for me. I didn't take any other actions. Consider editing the info. here. |
@rofrol ..Hmm was the OSX part in the description not obvious ;) |
For anyone arriving here recently, I'm just confirming that this is still an issue on MacOS Catalina as of August 2020, and that the provided solution by @bvssvni (Thank you!) still works. Only caveat is you'll need to add the $LIBRARY_PATH to your .zshrc, assuming you've migrated to it. |
Spent a long time debugging the "ld: library not found for -lSDL2" issue on an M1 Mac with Big Sur. What ended up solving it for me was actually installing SDL2 via macports instead of homebrew. I have no idea why that matters (perhaps someone more knowledgeable than I can say) but I figured I'd post in case someone else runs into the same issue. EDIT: While I can run vanilla SDL2, I have not been able to get SDL2_image to work. The instructions above work well for a Mac with an Intel CPU (I checked on my laptop) but it appears there is a problem with the M1. I attempted to use the SDL2 Framework route and found that the SDL2 libraries are not compatible with the ARM-64 architecture that the M1 uses (and SDL2 doesn't). This appears to be a fairly common problem that remains unaddressed as far as I can tell. |
Running % uname -r
20.6.0
% uname -m
arm64
% brew --version
Homebrew 3.2.13
Homebrew/homebrew-core (git revision ecf3c35ee41; last commit 2021-09-23)
% sudo brew link sdl2
Password:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system. However, % brew link sdl2
Warning: Already linked: /opt/homebrew/Cellar/sdl2/2.0.16
To relink, run:
brew unlink sdl2 && brew link sdl2 The link is now in /opt/homebrew/lib instead of /usr/local/lib. So the following solves the problem: % export LIBRARY_PATH="$LIBRARY_PATH:/opt/homebrew/lib" |
Make sure you run
and see what your default shell interpreter is. I was editing my bash_profile instead of my zprofile for the LIBRARY_PATH and was wondering why I couldn't get it to work. |
@kbolino Thank you!! |
None of the solutions above worked for me, unfortunately. However, editing Cargo.toml dependency like this helped: This uses github instead of local library, obviously, but it was fine in my case and maybe helps someone else who finds this answer. |
In the interest of the public, given that this is still the first page that comes up for me when I google this issue, it would be great if there could be an edit made to the description of the original post above to include the new updated information by @kbolino I.e the new path being:
|
@EriKWDev Updated! |
If you don't have
brew
installed, see #177This solution is relevant if you get an long error message when running
cargo build
ending in:ld: library not found for -lSDL2
Lacking permission to link SDL2
On some computers, the brew command fails to create the symlinks to the libraries it installs. This means the Rust compiler can not find them. To get permission to do this, use the
chown
command as following:Missing path in LIBRARY_PATH environment variable
The Homebrew package manager symlinks library to the directory
/usr/local/lib
. To use these libraries with Rust, you need to add it to theLIBRARY_PATH
environment variable. The commandecho $LIBRARY_PATH
will tell you if/usr/local/lib
is added. If it is missing, add the following to the~/.bash_profile
configuration file:export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib"
This will add the directory to the environment variable each time you start up a new Terminal window.
M1 Hardware
This solution was suggested by #175 (comment)
export LIBRARY_PATH="$LIBRARY_PATH:/opt/homebrew/lib
The text was updated successfully, but these errors were encountered: