ld: library not found

后端 未结 2 1288
星月不相逢
星月不相逢 2021-01-05 13:28

I\'m trying to build a project that depends on SDL2 library. I\'ve installed and linked it using homebrew:

> ls /usr/local/lib | grep SDL2
libSDL2-2.0.0.d         


        
相关标签:
2条回答
  • 2021-01-05 13:58

    /etc/paths is for executable files, not shared libraries. Same with the $PATH environmental variable set in .bash_profile. These are the paths searched for programs when you type a command in the terminal.

    What you need to do is change the linkers link path. See the answer to this question for details on how to set up the link path.

    0 讨论(0)
  • 2021-01-05 13:59

    I fixed the issue by adding /usr/local/lib to my $LIBRARY_PATH:

    For bash, in ~/.bash_profile:

    export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib"
    

    And for fish shell, in ~/.config/fish/config.fish:

    set -g -x LIBRARY_PATH $LIBRARY_PATH /usr/local/lib
    
    0 讨论(0)
提交回复
热议问题