首页 > 解决方案 > Mac OS:ld:找不到-lglfw的库

问题描述

构建我的项目我得到错误:

ld: library not found for -lglfw
clang: error: linker command failed with exit code 1 (use -v to see invocation)

但我已经安装了glfw,通过brew install glfw

brew list --versions | grep glfw
glfw 3.2.1

ls /usr/local/lib | grep glfw
libglfw.3.2.dylib
libglfw.3.dylib
libglfw.dylib


clang -v
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

MacOS : 10.14.1 (18B75)

标签: macosglfw

解决方案


看起来像添加export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib解决~/.bash_profile了这个问题,但我不确定它是否是没有副作用的优雅解决方案。


推荐阅读