问题描述
所以我正在使用GLFW和VSCode并编写:
#include <GLFW/glfw3.h>
int main(void)
{
GLFWwindow* window;
if (!glfwInit())
return -1;
window = glfwCreateWindow(640,480,"Hello World",NULL,NULL);
if (!window)
{
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
while (!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
return 0;
}
我使用g ++进行了编译,并输入了g++ main.cpp -o build -Wall -framework OpenGL -L/usr/local/Cellar/glfw/3.3.2/lib
,其输出为
ld: warning: text-based stub file /System/Library/Frameworks//OpenGL.framework/OpenGL.tbd and library file /System/Library/Frameworks//OpenGL.framework/OpenGL are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libglu.tbd and library file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libglu.dylib are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.tbd and library file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib are out of sync. Falling back to library file for linking.
Undefined symbols for architecture x86_64:
"_glfwCreateWindow",referenced from:
_main in main-2fb2c9.o
"_glfwInit",referenced from:
_main in main-2fb2c9.o
"_glfwMakeContextCurrent",referenced from:
_main in main-2fb2c9.o
"_glfwPollEvents",referenced from:
_main in main-2fb2c9.o
"_glfwSwapBuffers",referenced from:
_main in main-2fb2c9.o
"_glfwTerminate",referenced from:
_main in main-2fb2c9.o
"_glfwWindowShouldClose",referenced from:
_main in main-2fb2c9.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command Failed with exit code 1 (use -v to see invocation)
我用自制软件安装了GLFW 3。我在macOS High Sierra 10.13.6和VSCode版本上:1.48.2 提交:a0479759d6e9ea56afa657e454193f72aef85bd0 日期:2020-08-25T10:09:08.021Z 电子:7.3.2 铬:78.0.3904.130 Node.js:12.8.1 V8:7.8.279.23-electron.0 操作系统:Darwin x64 17.7.0 预先感谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)