glfwWindowHint的glfw错误 [英] glfw Errors with glfwWindowHint
本文介绍了glfwWindowHint的glfw错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经尝试过让本教程无效,但是它没有用.我不知道为什么它不起作用.我正在使用Ubuntu 14.04和GNU G ++命令.
I have tried fallowing this tutorial and it did not work. I do not know why it is not working. I'm using Ubuntu 14.04 and GNU G++ command.
代码:
#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
.如这里:
You should not link to glfw
, but link to glfw3
. As here:
g++ display.cpp -lglfw3 -o display.out
这篇关于glfwWindowHint的glfw错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文