3

I'm starting to learn OpenGL with Redbook version 4.3 and I need some linking help (I think). I am running Linux Mint and a Radeon HD 5000/6000/7350/8350 Series video card. I'm trying to compile and link the first program (triangles.cpp). I installed freeglut3, freeglut3-dev, libxi-dev, glew-utils, and libglew-dev. I found this linking command in an old version of OpenGL Superbible and I'm guessing I need to add -lGLEW.

g++ triangles.cpp -lX11 -lXi -lglut -lGL -lGLU -lGLEW

I get the following error:

/tmp/ccXSL2nx.o: In function `init()':
triangles.cpp:(.text+0x11d): undefined reference to `LoadShaders'
collect2: error: ld returned 1 exit status

I copied over vgl.h and LoadShaders.h and LoadShaders.cpp from the Redbook's source code download. What else am I missing?

Mike Glaz
  • 5,352
  • 8
  • 46
  • 73

1 Answers1

0

Try this:

g++ triangles.cpp LoadShaders.cpp -lX11 -lXi -lGL -lGLU -lGLEW -lglut -o triangles 

This will compile and link both triangles.cpp and LoadShaders.cpp into a single output file triangles.

Note, too, that you might not need "-lX11 -lXi". To test this try:

g++ triangles.cpp LoadShaders.cpp -lGL -lGLU -lGLEW -lglut -o triangles 

Also note that the order of libraries is important.

Community
  • 1
  • 1
Edward
  • 6,964
  • 2
  • 29
  • 55
  • If the order of libraries matters, this does not look like a good order. You normally want the higher level libraries first, so that the linker sees their references to lower level libraries before those lower level libraries are linked. So the order should be mostly about the opposite. – Reto Koradi Jul 20 '14 at 00:31