Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/162.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Can';t链接GLFW3:未定义的引用_C++_C++11_G++_Undefined Reference_Glfw - Fatal编程技术网

C++ Can';t链接GLFW3:未定义的引用

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

我意识到以前有人问过类似的问题(),但不幸的是,我仍然无法让它工作。欢迎任何帮助

以下是运行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目录中的内容:

以下是来源(但不应该有任何问题…):

#包括
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;
}