Tengo el mismo error que here. No hay solución allí y también voy a tratar de explicarlo más claramente, así que espero que alguien tenga la solución. También he instalado todo desde la respuesta a la pregunta this.Qt error: referencia no definida a 'gluOrtho2D'
Estoy tratando de compilar un programa que un amigo ha hecho en QT (linux). Lo probé en Windows y funciona muy bien, el problema es que no puedo ejecutarlo en Ubuntu 11.10.
Ésta es la salida al compilar QT:
...
glwidget.o:glwidget.cpp:function GLWidget::resizeGL(int, int): error: undefined reference to 'gluOrtho2D'
glwidget.o:glwidget.cpp:function GLWidget::projectScene(): error: undefined reference to 'gluOrtho2D'
make: Leaving directory...
collect2: ld returned 1 exit status
make: *** [QTapplication] Error 1
...
- glu.h y gl.h se #include.
- QT + = OpenGL se pone al .pro
No sé si se trata de un problema de Ubuntu 11.10. He leído que tiene algunos problemas con el enlazador aunque descargué "binutils-gold" que supuestamente lo arregló. También he intentado agregar manualmente la biblioteca haciendo clic derecho sobre los proyectos '.pro-> Agregar bibliotecas, pero no me deja agregar nada en "/ usr/include/GL".
Finalmente, aquí está la salida de compilación completa:
make: Entering directory `/home/daniel/Escritorio/Practica3-build-desktop-Desktop_Qt_4_8_0_for_GCC__Qt_SDK__Release'
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../QtSDK/Desktop/Qt/4.8.0/gcc/mkspecs/linux-g++ -I../Practica3 -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtCore -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtGui -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtOpenGL -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include -I../Practica3/SceneObjects -I../Practica3/SceneObjects/Auxiliar -I/usr/X11R6/include -I. -I. -I../Practica3 -I. -o main.o ../Practica3/main.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../QtSDK/Desktop/Qt/4.8.0/gcc/mkspecs/linux-g++ -I../Practica3 -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtCore -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtGui -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtOpenGL -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include -I../Practica3/SceneObjects -I../Practica3/SceneObjects/Auxiliar -I/usr/X11R6/include -I. -I. -I../Practica3 -I. -o mainwindow.o ../Practica3/mainwindow.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../QtSDK/Desktop/Qt/4.8.0/gcc/mkspecs/linux-g++ -I../Practica3 -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtCore -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtGui -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtOpenGL -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include -I../Practica3/SceneObjects -I../Practica3/SceneObjects/Auxiliar -I/usr/X11R6/include -I. -I. -I../Practica3 -I. -o glwidget.o ../Practica3/glwidget.cpp
../Practica3/glwidget.cpp:120:6: warning: unused parameter 'event' [-Wunused-parameter]
/home/daniel/QtSDK/Desktop/Qt/4.8.0/gcc/bin/moc -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../QtSDK/Desktop/Qt/4.8.0/gcc/mkspecs/linux-g++ -I../Practica3 -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtCore -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtGui -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtOpenGL -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include -I../Practica3/SceneObjects -I../Practica3/SceneObjects/Auxiliar -I/usr/X11R6/include -I. -I. -I../Practica3 -I. ../Practica3/mainwindow.h -o moc_mainwindow.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../QtSDK/Desktop/Qt/4.8.0/gcc/mkspecs/linux-g++ -I../Practica3 -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtCore -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtGui -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtOpenGL -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include -I../Practica3/SceneObjects -I../Practica3/SceneObjects/Auxiliar -I/usr/X11R6/include -I. -I. -I../Practica3 -I. -o moc_mainwindow.o moc_mainwindow.cpp
/home/daniel/QtSDK/Desktop/Qt/4.8.0/gcc/bin/moc -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../QtSDK/Desktop/Qt/4.8.0/gcc/mkspecs/linux-g++ -I../Practica3 -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtCore -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtGui -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtOpenGL -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include -I../Practica3/SceneObjects -I../Practica3/SceneObjects/Auxiliar -I/usr/X11R6/include -I. -I. -I../Practica3 -I. ../Practica3/glwidget.h -o moc_glwidget.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../QtSDK/Desktop/Qt/4.8.0/gcc/mkspecs/linux-g++ -I../Practica3 -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtCore -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtGui -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtOpenGL -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include -I../Practica3/SceneObjects -I../Practica3/SceneObjects/Auxiliar -I/usr/X11R6/include -I. -I. -I../Practica3 -I. -o moc_glwidget.o moc_glwidget.cpp
g++ -Wl,-O1 -Wl,-rpath,/home/daniel/QtSDK/Desktop/Qt/4.8.0/gcc/lib -o Practica3 main.o mainwindow.o glwidget.o scene.o pv2d.o regularpolygon.o obstacle.o sceneobject.o rectangle.o paintableobject.o segment.o point.o pen.o bouncingball.o circle.o moc_mainwindow.o moc_glwidget.o -L/home/daniel/QtSDK/Desktop/Qt/4.8.0/gcc/lib -L/usr/X11R6/lib -lQtOpenGL -lQtGui -lQtCore -lGL -lpthread
glwidget.o:glwidget.cpp:function GLWidget::resizeGL(int, int): error: undefined reference to 'gluOrtho2D'
make: Leaving directory `/home/daniel/Escritorio/Practica3-build-desktop-Desktop_Qt_4_8_0_for_GCC__Qt_SDK__Release'
glwidget.o:glwidget.cpp:function GLWidget::projectScene(): error: undefined reference to 'gluOrtho2D'
collect2: ld returned 1 exit status
make: *** [Practica3] Error 1
16:44:35: The process "/usr/bin/make" exited with code 2.
Error while building project Practica3 (target: Desktop)
When executing build step 'Make'
Independientemente de si se incluyen las cabeceras no es relevante aquí - usted tiene un error de enlazador no un error de compilación. Para solucionarlo, debes asegurarte de estar enlazando correctamente la biblioteca de glu. –
Pareces estar enlazando en gl con -lGL pero no con glu. Intente agregar -lGLU y vea si eso ayuda. –
posible duplicado de [referencia indefinida a 'gluOrtho2D '] (http://stackoverflow.com/questions/9326380/undefined-reference-to-gluortho2d) –