vscode g++ Link 失败:体系结构的未定义符号 x86_64
vscode g++ Link failure : Undefined symbols for architecture x86_64
基本信息:
- 系统:macOS High Sierra(10.13.6)
- editor : vs code(最新版本)
- 编译器:g++ (Xcode)
- 目标:部署GLFW + GLAD
问题描述:
最近,我正在学习做一些计算机图形相关的工作。一切都很顺利。但是,当我创建一个 window 来测试 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
我好像没有link 一些第三方文件。 我
在 glfw3.h.
中使用函数时,通过向 g++ 添加“-lglfw”参数解决了完全相同的问题
但是当遇到glad related function : 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",但不起作用。
只需通过将 "glad.c" 添加到 args 来告诉 g++ 编译 glad.c。我以为 glad.c 会默认编译。虽然不清楚是怎么回事,但是问题已经解决了
将 glad.c 添加到 Build Phases->Compile Sources
基本信息:
- 系统:macOS High Sierra(10.13.6)
- editor : vs code(最新版本)
- 编译器:g++ (Xcode)
- 目标:部署GLFW + GLAD
问题描述:
最近,我正在学习做一些计算机图形相关的工作。一切都很顺利。但是,当我创建一个 window 来测试 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
我好像没有link 一些第三方文件。 我
在 glfw3.h.
中使用函数时,通过向 g++ 添加“-lglfw”参数解决了完全相同的问题
但是当遇到glad related function : 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",但不起作用。
只需通过将 "glad.c" 添加到 args 来告诉 g++ 编译 glad.c。我以为 glad.c 会默认编译。虽然不清楚是怎么回事,但是问题已经解决了
将 glad.c 添加到 Build Phases->Compile Sources