Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

simple openGL program fails to link in ubuntu

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.

here's my sample program:

#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!

like image 419
knittl Avatar asked Mar 05 '11 15:03

knittl


People also ask

Where to get opengl32 lib?

The OpenGL library can usually be found by the name opengl32. dll under the \system32 folder, located in your system's root folder (usually c:\windows). Headers compatible with OpenGL are bundled with most compilers.


1 Answers

might be order - either reorder libs, or put them after opengl.cpp

like image 91
fazo Avatar answered Sep 28 '22 17:09

fazo