简单的openGL程序无法在ubuntu中链接 [英] simple openGL program fails to link in ubuntu
问题描述
我正在尝试进行opengl编程,但是无法编译我的第一个非常简单的程序.链接过程每次都会失败.我在stackoverflow上找到了这个答案,并且已经安装了所有软件包并告诉g ++要链接的库.
i'm trying to get into opengl programming, but fail to compile my first very very simple program. the linking process fails every time. i found this answer on stackoverflow, and have had all packages installed and told g++ which libraries to link against.
这是我的示例程序:
#include <GL/glut.h>
#include <GL/gl.h>
int main(int argc, char **argv) {
glutInit(&argc, argv);
return 0;
}
编译会导致链接器出现以下错误:
compiling results in the following error from the linker:
$ g++ -Wall -lglut -lGL -lGLU opengl.cpp
/tmp/cc1UAFPU.o: In function `main':
opengl.cpp:(.text+0x3b): undefined reference to `glutInit'
collect2: ld returned 1 exit status
有人对这个问题有任何想法吗?肯定有一些我想念的东西,但我只是看不到什么.任何解决此问题的提示都将受到高度赞赏!
anybody got any idea on this issue? there must be something which i am missing, but i just cannot see what. any hints to resolve this issue are highly appreciated!
推荐答案
可能是有序的-重新排序lib,或将它们放在opengl.cpp之后
might be order - either reorder libs, or put them after opengl.cpp
这篇关于简单的openGL程序无法在ubuntu中链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!