我之前已经意识到类似的东西(glfw3 compiling undefined references),但我仍然无法让它工作 . 欢迎任何帮助!
下面是运行make时的编译器输出:
g -std = c 11 -Wall -Wextra -Werror -pedantic-errors -I / usr / local / include -c -o Main.o Main.cpp g -std = c 11 -Wall -Wextra -Werror -pedantic- errors -I / usr / local / include -L / usr / local / lib -lglfw3 -lGL Main.o -o modernogl Main.o:在函数
main'中:Main.cpp :( . text 0x9):undefined reference to
glfwInit'Main.cpp :( . text 0x3b):未定义引用glfwCreateWindow'Main.cpp :( . text 0x4b):未定义引用
glfwTerminate'Main.cpp :( . text 0x5e):未定义引用glfwMakeContextCurrent 'Main.cpp :( . text 0x6c):未定义引用
glfwSwapBuffers'Main.cpp :( . text 0x71):未定义引用glfwPollEvents'Main.cpp :( . text 0x7d):未定义引用
glfwWindowShouldClose'Main .cpp :( . text 0x92):未定义引用glfwDestroyWindow'Main.cpp :( . text 0x97):未定义引用
glfwTerminate'collect2:错误:ld返回1退出状态make:*** [modernogl]错误1
以下是include和lib目录中的内容:http://imgur.com/e6qXSjB,fASlBUm#1
以下是来源(尽管......应该没有任何问题):
#include <GLFW/glfw3.h>
int main() {
if (!glfwInit()) {
return 1;
}
GLFWwindow* window {glfwCreateWindow(640, 480, "Modern OpenGL", nullptr, nullptr)};
if (!window) {
glfwTerminate();
return 1;
}
glfwMakeContextCurrent(window);
while (!glfwWindowShouldClose(window)) {
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
非常感谢你的帮助! - 埃里克
1 回答
我只有库“libglfw3.a”的静态版本,我需要它的共享版本“libglfw.so” . 确保使用BUILD_SHARED_LIBS = ON构建GLFW3!