C++ Can';t链接GLFW3:未定义的引用
我意识到以前有人问过类似的问题(),但不幸的是,我仍然无法让它工作。欢迎任何帮助 以下是运行make时的编译器输出: g++-std=c++11-Wall-Wextra-Werror-pedanticerrors-I/usr/local/include-c-o Main.o Main.cpp g++-std=c++11-Wall-Wextra-Werror-pedanticerrors-I/usr/local/include-L/usr/local/lib-lglfw3-lGL-Main.o-o modernogl Main.o:在函数“Main”中: Main.cpp:(.text+0x9):对“glfwInit”的未定义引用 Main.cpp:(.text+0x3b):对“glfwCreateWindow”的未定义引用 Main.cpp:(.text+0x4b):对“glfwTerminate”的未定义引用 Main.cpp:(.text+0x5e):对“glfwMakeContextCurrent”的未定义引用 Main.cpp:(.text+0x6c):对“glfwswapbuffer”的未定义引用 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目录中的内容: 以下是来源(但不应该有任何问题…):C++ Can';t链接GLFW3:未定义的引用,c++,c++11,g++,undefined-reference,glfw,C++,C++11,G++,Undefined Reference,Glfw,我意识到以前有人问过类似的问题(),但不幸的是,我仍然无法让它工作。欢迎任何帮助 以下是运行make时的编译器输出: g++-std=c++11-Wall-Wextra-Werror-pedanticerrors-I/usr/local/include-c-o Main.o Main.cpp g++-std=c++11-Wall-Wextra-Werror-pedanticerrors-I/usr/local/include-L/usr/local/lib-lglfw3-lGL-Main.o-o
#包括
int main(){
如果(!glfwInit()){
返回1;
}
GLFWwindow*窗口{glfwCreateWindow(640480,“现代OpenGL”,nullptr,nullptr)};
如果(!窗口){
glfwTerminate();
返回1;
}
glfwMakeContextCurrent(窗口);
而(!glfwWindowShouldClose(窗口)){
glfwSwapBuffers(窗口);
glfwPollEvents();
}
GLFW窗口(窗口);
glfwTerminate();
返回0;
}
非常感谢你的帮助!
-Erik我只有库“libglfw3.a”的静态版本,我需要它的共享版本“libglfw.so”。确保使用build_SHARED_LIBS=ON构建GLFW3 只是想说明一下:
cmake-DCMAKE\u INSTALL\u PREFIX=/usr-DBUILD\u SHARED\u LIBS=ON.
#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;
}