OSX:Clang / Ld说,即使存在并且所有参数都是正确的,它也可以找到静态库
我知道这将是一个愚蠢的错误,而且我知道帖子有类似的帖子,但是到目前为止没有任何帮助,所以我正在求助于新帖子。
我正在尝试编译最简单的GLFW Hello World示例。
在我的项目目录(我正在使用vscode)中,有一个main.cpp文件,以及我从glfw.org下载的glfw lib文件,我将其重命名为libglfw3.a(已预编译)我正在使用MacBook Air M1。
我正在尝试使用此命令进行编译:
clang -i/opt/homebrew/cellar/glfw/3.3.7/include -l/users // projects/-l libglfw3.a main.cpp -o helloglfw
输出i GET IS:
LD:未找到-llibglfw3.a的库 clang:错误:链接器命令因出口代码1失败(使用-v查看调用)
我显然很愚蠢,因为我一生看不到我在做错什么...
我尝试过的事情:
- 链接到GLFW的Homebrew版本,该版本包含一个.dylib Glfw
- 尝试链接libglfw3(无需.A扩展名)
- 将编译到对象文件,然后
- 使用g ++
- 分别使用g ++链接到ld,而不是使用-l flag并将完整路径粘贴到-l
- 祈祷和重新启动PC,以防万一。
- 等待它修复
一些帮助将不胜感激。
I know it's going to be a silly mistake, and I'm aware that there are similar posts however none have helped so far, so I'm resorting to a new post.
I'm trying to compile the simplest GLFW hello world example.
In my project directory (I'm using vscode) there is a main.cpp file, and the glfw lib file I downloaded from glfw.org which I renamed to libglfw3.a (It's precompiled) I am using a MacBook Air M1.
I'm trying to compile it with this command:
clang -I /opt/homebrew/Cellar/glfw/3.3.7/include -L /Users//projects/ -l libglfw3.a main.cpp -o helloglfw
The output I get is:
ld: library not found for -llibglfw3.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm clearly dumb because for the life of me I can't see what I'm doing wrong...
Things I've tried:
- linking to the homebrew version of glfw which contains a .dylib of glfw
- tried linking libglfw3 (without the .a extension)
- compiling to an object file and then linking with ld separately
- using g++
- Not using the -L flag and just pasting the full path into -l
- Praying and restarting the pc just in case.
- Waiting for it to fix itself
Some assistance would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧!我修复了它。显然,如果-L和-L参数之间没有空间,则可以工作。
所以命令看起来像这样:
不知道为什么,但是我做的一切...
OK SO! I fixed it. Apparently it works if there is NO SPACE between the -L and -l parameters.
so the command looks like this:
No clue why, but whatever I'm done...