无法链接GLFW3:未定义的引用 [英] Can't link GLFW3: undefined references

查看:2638
本文介绍了无法链接GLFW3:未定义的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现类似的问题之前( glfw3编译未定义的参考资料),但我仍然不能得到它工作不幸的是。欢迎任何帮助!

I realize something similar has been asked before (glfw3 compiling undefined references), but I still can't get it to work unfortunately. Any help is welcome!

以下是运行 make 时的编译器输出:

Below is the compiler output when running 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 -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

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.o: In function `main':

Main.cpp :(。 + 0x9):未定义引用`glfwInit'

Main.cpp:(.text+0x9): undefined reference to `glfwInit'

Main.cpp :(。text + 0x3b):未定义引用`glfwCreateWindow'

Main.cpp:(.text+0x3b): undefined reference to `glfwCreateWindow'

Main.cpp :( .text + 0x4b):未定义引用`glfwTerminate'

Main.cpp:(.text+0x4b): undefined reference to `glfwTerminate'

Main.cpp :(。未定义引用`glfwMakeContextCurrent'

Main.cpp:(.text+0x5e): undefined reference to `glfwMakeContextCurrent'

Main.cpp :( .text + 0x6c):未定义引用`glfwSwapBuffers'

Main.cpp:(.text+0x6c): undefined reference to `glfwSwapBuffers'

Main.cpp :(。text + 0x71):未定义的引用`glfwPollEvents'

Main.cpp:(.text+0x71): undefined reference to `glfwPollEvents'

Main.cpp :(。 glfwWindowShouldClose'

Main.cpp:(.text+0x7d): undefined reference to `glfwWindowShouldClose'

Main.cpp :( .text + 0x92):未定义引用`glfwDestroyWindow'

Main.cpp:(.text+0x92): undefined reference to `glfwDestroyWindow'

Main .cpp :(。text + 0x97):未定义的引用`glfwTerminate'

Main.cpp:(.text+0x97): undefined reference to `glfwTerminate'

collect2:error:ld返回1 exit status

collect2: error: ld returned 1 exit status

make: * [modernogl]错误1

make: * [modernogl] Error 1

目录包含在其中: http://imgur.com/e6qXSjB,fASlBUm#1

下面是源代码(虽然...应该没有任何问题):

Below is the source (there shouldn't be any problem with it though...):

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

非常感谢您的帮助!
- Erik

Thanks a lot for your help! - Erik

推荐答案

我只有静态版本的库libglfw3.a,我需要共享版本的libglfw.so。确保使用BUILD_SHARED_LIBS = ON!

I only had the static version of the library "libglfw3.a", I needed the shared version of it "libglfw.so". Make sure to build GLFW3 with BUILD_SHARED_LIBS=ON!

这篇关于无法链接GLFW3:未定义的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆