Zsh terminal outputs error when trying to link libraries installed with homebrew - Stack Overflow

I'm trying to create my own game engine in rust using sdl2 and opengl to create a graphics engine

I'm trying to create my own game engine in rust using sdl2 and opengl to create a graphics engine and the ecs or entity-component-system software architectural pattern for game logic seeing as rust is somewhat of a data oriented programming language. The current problem i'm running into as of right now is using the sdl2 crate to open a window seeing as this specific crate relies on the sdl2 library. A library which can be installed on a macbook using the homebrew package manager.

brew --install sdl2

the above terminal command uses homebrew to install the sdl2 library

As stated on the official sdl2 crate github page under the macos section more recent versions of hombrew place installed libraries into the /opt/homebrew/lib directory whereas older versions place installed libraries into the /usr/local/lib directory. And in order to make linking installed libraries easier we need to add the following line of code to the zsh environment file, a hidden file found in the home directory.

export LIBRARY_PATH="$LIBRARY_PATH:$(brew --prefix)/lib"

the above code can be placed into the ~/.zshenv file

In order to do this open a new terminal and type the following commands

cd ~
open .zshenv

the first line of the above code navigates to the home directory and the second opens the .zshenv file in text edit

Now you would think this would work yet it doesn't and we can see this right away if we open a new terminal. Immediately we get an error which prevents this from linking the sdl2 library to the sdl2 crate.

.zshenv:2: command not found: brew

So my question to anyone reading this post is how would I go about solving this? Any help is greatly appreciated.

I've tried a bunch of things and have spent an ungodly amount of time on just this issue. The one bandaid solution i've found to this problem is to just directly declare the path as such.

export LIBRARY_PATH="$LIBRARY_PATH:/opt/homebrew/lib"

the above code should be placed into the ~/.zshenv file replacing the previous line of code we added

Sure it works but is not the solution I am looking for. :)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742304513a4418667.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信