If you don't have brew installed, see #177
This 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:
brew install sdl2
sudo chown root:wheel /usr/local/bin/brew
brew unlink sdl2 && brew link sdl2
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 the LIBRARY_PATH environment variable. The command echo $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
If you don't have
brewinstalled, see #177This solution is relevant if you get an long error message when running
cargo buildending in:ld: library not found for -lSDL2Lacking 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
chowncommand 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_PATHenvironment variable. The commandecho $LIBRARY_PATHwill tell you if/usr/local/libis added. If it is missing, add the following to the~/.bash_profileconfiguration 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