Search code examples
c++opengllinkermakefilewxwidgets

Linker error in the makefile using OpenGL


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

Solution

  • 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)