【发布时间】:2018-11-03 13:12:29
【问题描述】:
基本信息:
- 系统:macOS High Sierra(10.13.6)
- 编辑器:vs代码(最新版)
- 编译器:g++ (Xcode)
- 目标:部署GLFW + GLAD
问题描述:
最近,我正在学习做一些计算机图形相关的工作。一切都很顺利。但是,当我创建一个窗口来测试 env.Link 时发生错误:
Undefined symbols for architecture x86_64:
"_gladLoadGLLoader", referenced from:
_main in main-5c211c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The terminal process terminated with exit code: 1
似乎我没有链接一些第三方文件。 我
在 glfw3.h 中使用函数时,通过在 g++ 中添加“-lglfw”参数解决了完全相同的问题。
但是当遇到glad相关函数:gladLoadGLLoader时,我不知道该怎么做。
我做过的事情:
-
可以找到头文件。
#include glad/glad.h #include GLFW/glfw3.h 已将文件“glad.c”放入工作区。
- 尝试添加“g++ -framework XXXXX”,但不起作用。
- 尝试添加“g++ -lglfw3”,但不起作用。
- 添加“g++ -L or I /usr/lib or /usr/local/lib or /usr/local/include”,但是不起作用。
【问题讨论】:
-
您可能需要明确引用具有
gladLoadGLLoader的.lib 文件,而不仅仅是指定它的路径。 -
感谢您的建议!
gladLoadGLLoader在glad.c文件中定义。老实说,我不知道在哪里可以找到具有该功能的 .lib 文件。很高兴我下载的只包含两个.h文件glad.hkhrplatform.h和一个src文件glad.c,我想我把它们放在正确的位置:/usr/local/include中的头文件和glad.c中的头文件工作区。 glad generator address
标签: c++ opengl visual-studio-code g++ glfw