簡體   English   中英

glfwWindowHint錯誤

[英]glfw Errors with glfwWindowHint

我已經嘗試過讓教程無效,但是它沒有用。 我不知道為什么它不起作用。 我正在使用Ubuntu 14.04和GNU G ++命令。

碼:

#include <GLFW/glfw3.h>

int main(void) {
    glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); 
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

    glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);


    GLFWwindow* window = glfwCreateWindow(800, 600, "OpenGL", NULL, NULL);

    glfwMakeContextCurrent(window);

    while(!glfwWindowShouldClose(window)) {
            glfwSwapBuffers(window);
            glfwPollEvents();
    }

    glfwTerminate();
}

終奌站:

command: g++ display.cpp -lglfw -o display.out
/tmp/cci33O9I.o: In function `main':
display.cpp:(.text+0x18): undefined reference to `glfwWindowHint'
display.cpp:(.text+0x27): undefined reference to `glfwWindowHint'
display.cpp:(.text+0x36): undefined reference to `glfwWindowHint'
display.cpp:(.text+0x45): undefined reference to `glfwWindowHint'
display.cpp:(.text+0x54): undefined reference to `glfwWindowHint'
display.cpp:(.text+0x73): undefined reference to `glfwCreateWindow'
display.cpp:(.text+0x83): undefined reference to `glfwMakeContextCurrent'
display.cpp:(.text+0xa2): undefined reference to `glfwWindowShouldClose'
collect2: error: ld returned 1 exit status

您不應鏈接到glfw ,而應鏈接到glfw3 如這里:

g++ display.cpp -lglfw3 -o display.out

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM