我正在尝试构建一个依赖于SDL2库的项目。我已经使用homebrew安装并链接了它:
> ls /usr/local/lib | grep SDL2
libSDL2-2.0.0.dylib
libSDL2.a
libSDL2.dylib
libSDL2_test.a
libSDL2main.a
我还将/usr/local/lib
添加到了/etc/paths
和~/.bash_profile
文件中:
> cat /etc/paths
/usr/local/lib
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
然而,当我尝试构建该项目时,仍然出现以下错误:
error: linking with `cc` failed: exit code: 1
note: cc '-m64' '-L' (...) '-lSDL2'
ld: library not found for -lSDL2
clang: error: linker command failed with exit code 1 (use -v to see invocation)
为什么会发生这种情况,我该如何修复它?