链接器:文件是为存档构建的,不是被链接的体系结构 (x86_64) GLFW
Linkers: file was built for archive which is not the architecture being linked (x86_64) GLFW
你好,这个问题让我抓狂,我需要你的帮助。
我在 IOS High Sierra v10.13.6 上,我正在尝试在 mac 上的 VSC 上尝试 OpenGL XCode。
所以我已经下载了右边的库 GLFW OS。
我尝试了 GLWF website.
中的基本示例
#include "../GLFW/glfw3.h"
// g++ -v main.cpp -o main.o -L/Library/Developer/CommandLineTools/usr/include -lglfw3 -framework OpenGL
// file was built for archive which is not the architecture being linked (x86_64):
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT);
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
我有以下目录:
当我执行此命令时:
g++ -v main.cpp -o main.o -L/Library/Developer/CommandLineTools/usr/include -lglfw3 -framework OpenGL
我在终端中出现以下错误:
Undefined symbols for architecture x86_64:
"_glfwCreateWindow", referenced from:
_main in main-ca9141.o
"_glfwInit", referenced from:
_main in main-ca9141.o
"_glfwMakeContextCurrent", referenced from:
_main in main-ca9141.o
"_glfwPollEvents", referenced from:
_main in main-ca9141.o
"_glfwSwapBuffers", referenced from:
_main in main-ca9141.o
"_glfwTerminate", referenced from:
_main in main-ca9141.o
"_glfwWindowShouldClose", referenced from:
_main in main-ca9141.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我知道我来自这个警告:
ld: warning: ignoring file /Library/Developer/CommandLineTools/usr/include/libglfw3.a, file was built for archive which is not the architecture being linked (x86_64): /Library/Developer/CommandLineTools/usr/include/libglfw3.a
我用lipo命令查看了库,说他的架构是x86_64!
我不知道为什么它不起作用,你能帮我吗?
提前致谢。
我想说我已经找到了解决问题的办法。
您必须仔细检查 libglfw3.a 库是否在良好的体系结构中编译 是 x86_64.
这里官方link下载右边的GLFW库OS
这里还有你需要运行编译的命令:
需要确保通过-L指定库的路径
g++ main.cpp -o main -L/Library/Developer/CommandLineTools/usr/include -lglfw3 -framework Cocoa -framework OpenGL -framework IOKit
希望对以后遇到同样问题的开发者有所帮助
你好,这个问题让我抓狂,我需要你的帮助。 我在 IOS High Sierra v10.13.6 上,我正在尝试在 mac 上的 VSC 上尝试 OpenGL XCode。 所以我已经下载了右边的库 GLFW OS。 我尝试了 GLWF website.
中的基本示例#include "../GLFW/glfw3.h"
// g++ -v main.cpp -o main.o -L/Library/Developer/CommandLineTools/usr/include -lglfw3 -framework OpenGL
// file was built for archive which is not the architecture being linked (x86_64):
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT);
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
我有以下目录:
当我执行此命令时:
g++ -v main.cpp -o main.o -L/Library/Developer/CommandLineTools/usr/include -lglfw3 -framework OpenGL
我在终端中出现以下错误:
Undefined symbols for architecture x86_64:
"_glfwCreateWindow", referenced from:
_main in main-ca9141.o
"_glfwInit", referenced from:
_main in main-ca9141.o
"_glfwMakeContextCurrent", referenced from:
_main in main-ca9141.o
"_glfwPollEvents", referenced from:
_main in main-ca9141.o
"_glfwSwapBuffers", referenced from:
_main in main-ca9141.o
"_glfwTerminate", referenced from:
_main in main-ca9141.o
"_glfwWindowShouldClose", referenced from:
_main in main-ca9141.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我知道我来自这个警告:
ld: warning: ignoring file /Library/Developer/CommandLineTools/usr/include/libglfw3.a, file was built for archive which is not the architecture being linked (x86_64): /Library/Developer/CommandLineTools/usr/include/libglfw3.a
我用lipo命令查看了库,说他的架构是x86_64! 我不知道为什么它不起作用,你能帮我吗?
提前致谢。
我想说我已经找到了解决问题的办法。 您必须仔细检查 libglfw3.a 库是否在良好的体系结构中编译 是 x86_64.
这里官方link下载右边的GLFW库OS
这里还有你需要运行编译的命令:
需要确保通过-L指定库的路径
g++ main.cpp -o main -L/Library/Developer/CommandLineTools/usr/include -lglfw3 -framework Cocoa -framework OpenGL -framework IOKit
希望对以后遇到同样问题的开发者有所帮助