PDA

View Full Version : gluPerspective and gluOrtho2d not found in QGLWidget



litedrive
13th January 2012, 18:25
...And I'm running the most recent version of Qt (which, unless I'm wrong, is 4.8.0).

What could be the issue here? So far the project I'm working on builds on Ubuntu and Windows perfectly fine, yet it won't build on Arch Linux because of this. I spoke with someone else who was running Arch as well and he too had problems building the project. The interesting thing is that while he got his Qt from Pacman, I wound up downloading the QtSDK. I'll post an example of the ppdirectives:


#pragma once
#include <list>
#include <QGLWidget>
#include <GL/glext.h>
#include "SharedPtr.h"
#include "Shape.h"
#include "Vec2f.h"

And the actual header file:




class BoxOfShapes
: public QGLWidget
{
Q_OBJECT
public:
explicit BoxOfShapes( QWidget* parent, float width, float height );

virtual ~BoxOfShapes( void );

void addShape( std::shared_ptr< Shape > shape );

public slots:
void doPhysics( void );

void resetWorld( void );

signals:
void numShapesChanged( int numShapes );

protected:
std::list< shared_ptr< Shape > > collide( std::list< shared_ptr< Shape > > toCollide );

std::list< shared_ptr< Shape > > explode( std::list< shared_ptr< Shape > > toExplode );

int heightForWidth( int w ) { return w; }

void initializeGL( void );

void move( std::list< shared_ptr< Shape > >& toMove );

void paintGL( void );

virtual void Render( void );

void resizeGL( int width, int height );

Vec2f mDims;

std::list< shared_ptr< Shape > > mShapes;

std::list< shared_ptr< Shape > > mParticles;
};





And the error...


void BoxOfShapes::paintGL( void )
{
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluOrtho2D( 0, width(), 0, height() );
glClear( GL_COLOR_BUFFER_BIT );

Render();
}



‘gluOrtho2D’ was not declared in this scope




void BoxOfShapes::resizeGL( int width, int height )
{
if ( height == 0 ) height = 1;
if ( width == 0 ) width = 1;

glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();

gluPerspective( 45.0f, (GLfloat)width / (GLfloat)height, 0.1f, 8.0f );
glMatrixMode( GL_MODELVIEW );
}




‘gluPerspective’ was not declared in this scope



I have no idea how this could be, but for whatever reason it appears that QGLWidget isn't registering the glu library. Is there a way to edit this?

wysota
13th January 2012, 21:04
Qt has nothing to do with this. gluPerspective() is a function from GLU library. If you link your project against it, all will be fine.

danadn
25th February 2012, 20:00
Qt has nothing to do with this. gluPerspective() is a function from GLU library. If you link your project against it, all will be fine.

How do I link my project against it?

I'm sorry if it's really simple but I just haven't found how to do it and I have the same problem.

Also I've #included "GL/glu.h" at the header and the error message changes to "GluOrto2d undefined reference". Any idea?

[SOLVED]

For Ubuntu (>= 11.10) is necessary to install an extra package because the linker doesn't links correctly:

sudo apt-get install binutils-gold

Tong
8th September 2013, 15:43
Try to add the title file " #include "GL/glu.h" "