C:关于ubuntu未定义引用的glfw3
发布时间:2020-12-16 10:34:41 所属栏目:百科 来源:网络整理
导读:我正在尝试从 this教程编译程序. #include GLFW/glfw3.h#include stdlib.h#include stdio.hstatic void error_callback(int error,const char* description){ fputs(description,stderr);}static void key_callback(GLFWwindow* window,int key,int scancode
我正在尝试从
this教程编译程序.
#include <GLFW/glfw3.h> #include <stdlib.h> #include <stdio.h> static void error_callback(int error,const char* description) { fputs(description,stderr); } static void key_callback(GLFWwindow* window,int key,int scancode,int action,int mods) { if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) glfwSetWindowShouldClose(window,GL_TRUE); } int main(void) { GLFWwindow* window; glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(EXIT_FAILURE); window = glfwCreateWindow(640,480,"Simple example",NULL,NULL); if (!window) { glfwTerminate(); exit(EXIT_FAILURE); } glfwMakeContextCurrent(window); glfwSetKeyCallback(window,key_callback); while (!glfwWindowShouldClose(window)) { float ratio; int width,height; glfwGetFramebufferSize(window,&width,&height); ratio = width / (float) height; glViewport(0,width,height); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-ratio,ratio,-1.f,1.f,-1.f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotatef((float) glfwGetTime() * 50.f,0.f,1.f); glBegin(GL_TRIANGLES); glColor3f(1.f,0.f); glVertex3f(-0.6f,-0.4f,0.f); glColor3f(0.f,0.f); glVertex3f(0.6f,1.f); glVertex3f(0.f,0.6f,0.f); glEnd(); glfwSwapBuffers(window); glfwPollEvents(); } glfwDestroyWindow(window); glfwTerminate(); exit(EXIT_SUCCESS); } 我尝试编译时得到的结果: /usr/local/lib/libglfw3.a(x11_window.c.o): In function `_glfwPlatformCreateCursor': x11_window.c:(.text+0x2d91): undefined reference to `XcursorImageCreate' x11_window.c:(.text+0x2e61): undefined reference to `XcursorImageLoadCursor' x11_window.c:(.text+0x2e75): undefined reference to `XcursorImageDestroy' 我用这个命令 g++ glfw.o -lglfw3 -lGL -lGLU -lX11 -lXxf86vm -lXrandr -lpthread -lXi -lm -lalleg 在Ubuntu 13.10上运行 我到处寻找,安装了box2d,glfw,glfw3,allegro和一些libs – 原因是我经历了远程提到glfw和未定义引用的每一个讨论,并且由于五个小时的僵局导致我的挫败感,安装了任何库被提到了.结果保持不变.我不知道从哪里开始.是什么原因导致这个问题? 解决方法
直到先生. AndonM.Coleman发布了这个问题的答案(他在评论中做了),问题在于缺少-lXcursor
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |