首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在Ubuntu中安装OpenGL/Glut库

在Ubuntu中安装OpenGL/Glut库
EN

Stack Overflow用户
提问于 2014-11-08 22:10:01
回答 1查看 1.6K关注 0票数 1

我尝试按照本教程-> http://kiwwito.com/installing-opengl-glut-libraries-in-ubuntu/为ubuntu安装OpenGL库,但是当我尝试运行示例程序时,我得到了这个错误信息。

代码语言:javascript
运行
复制
test2.c:(.text+0x1d): undefined reference to `glClearColor'
test2.c:(.text+0x27): undefined reference to `glClear'
test2.c:(.text+0x2c): undefined reference to `glFlush'
/tmp/ccNGbmFL.o: In function `main':
test2.c:(.text+0x50): undefined reference to `glutInit'
test2.c:(.text+0x5a): undefined reference to `glutInitDisplayMode'
test2.c:(.text+0x69): undefined reference to `glutInitWindowPosition'
test2.c:(.text+0x78): undefined reference to `glutInitWindowSize'
test2.c:(.text+0x82): undefined reference to `glutCreateWindow'
test2.c:(.text+0x8c): undefined reference to `glutDisplayFunc'
test2.c:(.text+0x91): undefined reference to `glutMainLoop'

当我删除这些函数,只留下#include <GL/glut.h>时,程序运行良好。我也尝试过这个http://www.opengl-tutorial.org/beginners-tutorials/tutorial-1-opening-a-window/#Building_on_Linux安装指南,但它也不起作用。此外,我还尝试安装eclipse并将这些库添加到C++链接器中。Eclipse控制台输出为:

代码语言:javascript
运行
复制
16:02:45 **** Incremental Build of configuration Debug for project opengl_glut ****
make all 
Building file: ../main.cpp
Invoking: Cross G++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp"
Finished building: ../main.cpp

Building target: opengl_glut
Invoking: Cross G++ Linker
g++  -o "opengl_glut"  ./main.o   -lglut -lGL -lm -lXrandr -lXi -lX11 -lXxf86vm -lpthread -lglfw3 -lGLU
/usr/bin/ld: cannot find -lglfw3
makefile:44: recipe for target 'opengl_glut' failed
collect2: error: ld returned 1 exit status
make: *** [opengl_glut] Error 1

如何修复这些错误?

EN

回答 1

Stack Overflow用户

发布于 2014-11-08 22:35:20

对于您的第一个问题,通过添加-lglut链接到glut。您必须链接到您使用的库。仅仅包含头部是不够的。

对于第二个问题,从库中删除glfw3。不知道为什么会这样。您使用的是glut,而不是glfw。如果教程也使用了glfw,那么另一个选择就是安装它,或者找一个没有安装的教程。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26817954

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档