Skip to content

Information on how to get SDL2 working on OSX #175

Closed
@bvssvni

Description

@bvssvni

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions