0

My ubuntu installation recently died and I'm now reconstruction everything.

I have a file that I know recently compiled and worked with the same comment. This is a simple opengl-glut based program.

It compiles with the following line :

g++ -lGL -lGLU -lglut -I . *.cp

this gives the following error code:

main.cpp:(.text+0x2de): undefined reference to `glGetDoublev'
/tmp/cc9vO929.o: In function `tbVisuTransform()':
main.cpp:(.text+0x2fd): undefined reference to `glMultMatrixd'
/tmp/cc9vO929.o: In function `tbMotionFunc(int, int)':
main.cpp:(.text+0x4f5): undefined reference to `glLoadIdentity'
main.cpp:(.text+0x523): undefined reference to `glRotatef'
main.cpp:(.text+0x52d): undefined reference to `glMultMatrixd'
main.cpp:(.text+0x53c): undefined reference to `glGetDoublev'
main.cpp:(.text+0x649): undefined reference to `glLoadIdentity'
main.cpp:(.text+0x665): undefined reference to `glRotatef'
main.cpp:(.text+0x66f): undefined reference to `glMultMatrixd'
main.cpp:(.text+0x67e): undefined reference to `glGetDoublev'
main.cpp:(.text+0x724): undefined reference to `glutPostRedisplay'
/tmp/cc9vO929.o: In function `tbRotate(double, double, double, double)':
main.cpp:(.text+0x78c): undefined reference to `glLoadIdentity'
main.cpp:(.text+0x7b5): undefined reference to `glRotatef'
main.cpp:(.text+0x7bf): undefined reference to `glMultMatrixd'
main.cpp:(.text+0x7ce): undefined reference to `glGetDoublev'

this goes on for quite a while. I have already installed the build essential and freeglut. sudo apt-get install build-essential sudo apt-get install freeglut3 freeglut3-dev

anybody got any ideas?

I already tried what they said here: Error with GLUT compile in ubuntu

Note that I upgraded from ubuntu 12.04 to 14.04 if that matters.

Community
  • 1
  • 1
Thijser
  • 2,625
  • 1
  • 36
  • 71
  • Look at [this](http://stackoverflow.com/questions/45135/linker-order-gcc) and [this](http://stackoverflow.com/a/12574400/680982). – Csq Jun 17 '14 at 11:28
  • 1
    Not solving your problem, but you should also consider -Wall -Werror –  Jun 17 '14 at 11:29
  • But those are about the order however I know for a fact that this line has in the past managed to compile this program. So changing the order should not matter unless some of these libs have suddenly gained dependancy between their current version and the on used a few month ago. – Thijser Jun 17 '14 at 11:29
  • 1
    For the updated question: see [this](http://stackoverflow.com/questions/7826448/linking-libraries-with-gcc-order-of-arguments) – Csq Jun 17 '14 at 11:42
  • For one thing, the wildcard `*.cp` will not catch `main.cpp`. So you have not pasted your actual build command here. I would also suggest you put the input file wildcard ***before*** the libraries. – Andon M. Coleman Jun 17 '14 at 15:43

1 Answers1

1

Based on this and this links, Ubuntu has changed the default linking strategy in Oneiric (Ubuntu 11.10).

As Oneiric and later versions use the --as-needed flag by default, the order of the libraries does matter in Ubuntu.

Csq
  • 5,775
  • 6
  • 26
  • 39
  • Those seem to focus on the difference between pre and after 11.10 while I upgraded from 12.04 to 14.04 so are these still relevant? – Thijser Jun 17 '14 at 12:00
  • ok got it should have put *cpp in front of the rest. rather then behind it. – Thijser Jun 17 '14 at 20:19