0

While compiling my project using OpenGL and wxWidgets under ubuntu 14.04, i got this error (to link the .o):

cc   GUI.o Fenetre.o Vue_OpenGL.o Enceinte.o Systeme.o GLNeon.o GLArgon.o Particule.o Vecteur.o  `wx-config --libs gl,core,base` -lGLU -lGL -lglut -lrt -o GUI
/usr/bin/ld: GUI.o: référence au symbole non défini «__cxa_pure_virtual@@CXXABI_1.3»
//usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [GUI] Erreur 1

I installed all the libraries (freeglut3, freeglut3 -dev, ...)

here is my makefile:

CXX=g++-4.8
CXXFLAGS += `wx-config --cxxflags` -std=c++11 
CXXFLAGS +=  -g
LDLIBS   += `wx-config --libs gl,core,base` -lGLU -lGL -lglut -lrt

TARGETS=GUI

all:: $(TARGETS)


Fenetre.o : Fenetre.cc Fenetre.h

GUI.o : GUI.cc GUI.h

Vue_OpenGL.o : Vue_OpenGL.cc Vue_OpenGL.h

Vecteur.o: Vecteur.cc Vecteur.h

Systeme.o: Systeme.cc Systeme.h GenerateurAleatoire.h

Particule.o: Particule.cc Particule.h

GLArgon.o: GLArgon.cc GLArgon.h

GLNeon.o: GLNeon.cc GLNeon.h

Enceinte.o: Enceinte.h Enceinte.cc

GUI : GUI.o Fenetre.o Vue_OpenGL.o Enceinte.o Systeme.o GLNeon.o GLArgon.o Particule.o Vecteur.o
genpfault
  • 51,148
  • 11
  • 85
  • 139
  • possible duplicate of [Linker order - GCC](http://stackoverflow.com/questions/45135/linker-order-gcc) – Bartek Banachewicz May 22 '14 at 12:58
  • Adding `-lstdc++` to the end of your `LDLIBS` should take care of this. – Andon M. Coleman May 22 '14 at 13:38
  • Hi, so i added that and i had a new error cc GUI.o Fenetre.o Vue_OpenGL.o Enceinte.o Systeme.o GLNeon.o GLArgon.o Particule.o Vecteur.o `wx-config --libs gl,core,base` -lGLU -lGL -lglut -lrt -lstdc++ -o GUI /usr/bin/ld: Systeme.o: référence au symbole non défini «cos@@GLIBC_2.2.5» //lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make: *** [GUI] Erreur 1 Any idea ? – Badrechkova May 22 '14 at 18:27
  • You need to add `-lm` as well ;) The linker is basically telling you what you need to do: lib **m** .so.6 is `-lm`. – Andon M. Coleman May 22 '14 at 22:12

1 Answers1

0

You must use c++, not cc, to link the C++ programs. To do this, you need to define the recipe for linking explicitly instead of relying on the implicit one, i.e. GUI.o: $(OBJECTS) $(CXX) -o $@ $(LDFLAGS) $(OBJECTS) $(LIBS)

VZ.
  • 21,740
  • 3
  • 39
  • 42