Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) undefined reference to 'gluPerspective'

 

Link error.

 

 

 

 

 

Full error message

 

/MyFolder/main.o:: In function 'main':
/MyFolder/main.cpp:7: error: undefined reference to 'gluPerspective'
:: error: collect2: ld returned 1 exit status

 

 

 

 

 

 

Cause

 

IDE: Qt Creator 2.0.0

Project type: Qt4 Console Application

Selected required modules: QtCore

Compiler: G++ 4.4.1

 

The following source code was used:

 

#include <GL/glu.h>

int main()
{
  gluPerspective (0,0,0,0);
}

 

The following project file was used:

 

#-------------------------------------------------
#
# Project created by QtCreator 2010-09-13T09:39:02
#
#-------------------------------------------------
QT += core
QT -= gui
TARGET = MyTarget
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp

 

 

 

 

 

Solution

 

You need to link against the GLU library. Add the following line to your project file:

 

LIBS += -L/usr/local/lib -lGLU

 

Note that the shown code will not give a correctly-running program, because it is too incomplete.

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict