似乎无法让我的glfw3文件链接到Linux上的code :: blocks

时间:2019-02-06 20:03:04

标签: c++ opengl codeblocks glfw

我正在设置代码块以使用glfw3,但是请继续获取此信息:

我尝试将gl,glflw3添加到链接器

我要运行的代码:

#include <GLFW/glfw3.h>


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

结果:

-------------- Build: Debug in VulkanTutorial (compiler: GNU GCC Compiler)---------------

g++ -L../../../../../Downloads/glfw-3.2.1/include -o bin/Debug/VulkanTutorial obj/Debug/main.o   -lGL -lGLEW -lglfw3 -lglfw3
/usr/bin/ld: //usr/local/lib/libglfw3.a(vulkan.c.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
/usr/bin/ld: //lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))

我也尝试了这篇glfw3 error: DSO Missing from command line帖子中的内容,但没有成功。可能要做的是不确切知道将make文件放在何处。我将其放在我的项目文件夹中并运行它,并获得了以下

g++  -o out main.o -lGL -lGLU -lglfw3 -lX11 -lXxf86vm -lXrandr -pthread -lXi -ldl
/usr/bin/ld: //usr/local/lib/libglfw3.a(x11_init.c.o): in function `initExtensions':
x11_init.c:(.text+0x1b87): undefined reference to `XineramaQueryExtension'
/usr/bin/ld: x11_init.c:(.text+0x1ba1): undefined reference to `XineramaIsActive'
/usr/bin/ld: //usr/local/lib/libglfw3.a(x11_init.c.o): in function `_glfwCreateCursorX11':
x11_init.c:(.text+0x243f): undefined reference to `XcursorImageCreate'
/usr/bin/ld: x11_init.c:(.text+0x256c): undefined reference to `XcursorImageLoadCursor'
/usr/bin/ld: x11_init.c:(.text+0x257c): undefined reference to `XcursorImageDestroy'
/usr/bin/ld: //usr/local/lib/libglfw3.a(x11_monitor.c.o): in function `_glfwPlatformGetMonitors':
x11_monitor.c:(.text+0x6ca): undefined reference to `XineramaQueryScreens'
collect2: error: ld returned 1 exit status
make: *** [Makefile:11: out] Error 1

我希望可以从此代码中打开一个小窗口。

0 个答案:

没有答案