C++ 我不知道';我不认为我的代码把g++;说有吗?
因此,我使用GLFW和VSCode编写了:C++ 我不知道';我不认为我的代码把g++;说有吗?,c++,macos,opengl,clang++,C++,Macos,Opengl,Clang++,因此,我使用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) { glfwT
#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;
}
我用自制软件安装了GLFW3。我使用的是macOS High Sierra 10.13.6和VSCode版本:1.48.2
提交:A0479759D6E9EA56AFA657E45454193F72AEF85BD0
日期: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
操作系统:达尔文x64 17.7.0
提前谢谢 看来,第一条警戒线至关重要。OpenGL安装似乎有问题。只是在黑暗中拍摄:检查您是否安装了发行版或开发版。请试着为你的问题写一个更好的标题,因为它非常混乱,信息量也不多。你没有链接到glfw库
-L
表示在哪里查找库,但不表示要查找什么库。homebrew将所有内容链接到/usr/local/lib
,因此我想您最好使用它,而不是选择特定于版本的路径,否则您将无法从升级中获益。尝试ls-l/usr/local/lib/*glfw*
查看符号链接。尝试g++main.cpp-o build-Wall-l/usr/local/Cellar/glfw/3.3.2/lib-lglfw3-framework OpenGL
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)