You are not logged in.

#1 2010-02-16 03:24:43

dwende
Member
From: Israel
Registered: 2008-12-04
Posts: 27

Problem compiling with glut - gluPerspective

I am going through the opengl tutorials on http://www.videotutorialsrock.com/ and have
a problem similar to that mentioned in an old posting:
http://bbs.archlinux.org/viewtopic.php? … 65#p709765

I am having a similar compile problem with gluPerspective.
Any ideas anyone? The error is:

[dwende@AMD cube]$ make
g++ -Wall -o cube main.cpp imageloader.cpp -lglut -lGL
imageloader.cpp: In function 'Image* loadBMP(const char*)':
imageloader.cpp:141: warning: suggest parentheses around '&&' within '||'
/tmp/ccTcVEcJ.o: In function `handleResize(int, int)':
main.cpp:(.text+0x183): undefined reference to `gluPerspective'
collect2: ld returned 1 exit status
make: *** [cube] Error 1
[dwende@AMD cube]$

I have freeglut installed as seen here:

[dwende@AMD cube]$ pacman -Qi freeglut
Name           : freeglut
Version        : 2.6.0-1
URL            : http://freeglut.sourceforge.net/
Licenses       : MIT
Groups         : None
Provides       : glut
Depends On     : libxxf86vm  mesa  libxi
Optional Deps  : None
Required By    : gtkglarea  jasper  swftools
Conflicts With : glut
Replaces       : glut
Installed Size : 720.00 K
Packager       : Eric Belanger <eric@archlinux.org>
Architecture   : i686
Build Date     : Thu 31 Dec 2009 01:08:51 AM IST
Install Date   : Tue 16 Feb 2010 05:05:31 AM IST
Install Reason : Installed as a dependency for another package
Install Script : No
Description    : Provides functionality for small OpenGL programs

The first part of main.cpp is:

#include <iostream>
#include <stdlib.h>

#ifdef __APPLE__
#include <OpenGL/OpenGL.h>
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

#include "imageloader.h"

Thanks

Offline

#2 2010-02-16 11:28:06

sr
Member
Registered: 2009-10-12
Posts: 51

Re: Problem compiling with glut - gluPerspective

gluPerspective was apparently deprecated in OpenGL 3.0, and removed in 3.1 - is that why you see a problem?

glxinfo | grep "version string"

The OpenGL wiki article here might help.

Offline

#3 2010-02-16 13:39:36

the_isz
Member
Registered: 2009-04-14
Posts: 280

Re: Problem compiling with glut - gluPerspective

Did you link against glu?

Edit: I just re-read your post and saw that you don't tongue Try adding '-lglu' to
your compiler call.

Last edited by the_isz (2010-02-16 13:40:47)

Offline

#4 2010-03-18 00:51:22

ChrisODonnell
Member
Registered: 2010-03-06
Posts: 8

Re: Problem compiling with glut - gluPerspective

I'm having a similar problem (can't find gluPerspective or gluLookAt):

#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

When I try to compile with -lglu, I get:

/usr/bin/ld: cannot find -lglu

Similarly, I have freeglut installed.

If both of these functions are deprecated, I suppose it would be good practice for me to recode some. As far as I can tell, though, gluLookAt should be intact.

Offline

#5 2010-03-18 08:13:57

the_isz
Member
Registered: 2009-04-14
Posts: 280

Re: Problem compiling with glut - gluPerspective

ChrisODonnell wrote:

I'm having a similar problem (can't find gluPerspective or gluLookAt):

#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

When I try to compile with -lglu, I get:

/usr/bin/ld: cannot find -lglu

Similarly, I have freeglut installed.

If both of these functions are deprecated, I suppose it would be good practice for me to recode some. As far as I can tell, though, gluLookAt should be intact.

Sorry to correct you, but this isn't a similar problem. The TO's problem was (as
I assume) that he didn't link against the glu library.

You, however, are linking against the glu library, but your linker can't find
it. If your compiler accepted your code with gluLookAt inside, it means that the
function is defined somewhere in the headers you included. If you didn't include
the glu.h header, I assume the function definition might have moved.

If you really only include glut.h, make sure you link against the glut library
and see if that fixes your problem.

Offline

#6 2010-03-18 14:52:09

ChrisODonnell
Member
Registered: 2010-03-06
Posts: 8

Re: Problem compiling with glut - gluPerspective

I am linking with -lglut. Specifically, I call

gcc -Wall -g -pg -lglut -lm -o watershed vector.o tin.o primitives.o watershed.o rtimer.o ridge.o draw_tin.o

And I get the error

/home/chris/Coding/watershedtin/draw_tin.c:319: undefined reference to `gluPerspective'
/home/chris/Coding/watershedtin/draw_tin.c:322: undefined reference to `gluLookAt'

This is why I said I had a similar problem to the TO.

Offline

#7 2010-03-18 15:00:05

the_isz
Member
Registered: 2009-04-14
Posts: 280

Re: Problem compiling with glut - gluPerspective

In that case, please try '-lGLU'. That library is supplied by mesa (which
freeglut depends on) and should be the one you seek.

Offline

#8 2010-03-18 15:33:29

ChrisODonnell
Member
Registered: 2010-03-06
Posts: 8

Re: Problem compiling with glut - gluPerspective

Success! Thanks a bunch.

Offline

#9 2010-03-18 16:29:02

the_isz
Member
Registered: 2009-04-14
Posts: 280

Re: Problem compiling with glut - gluPerspective

ChrisODonnell wrote:

Success! Thanks a bunch.

You're welcome smile

Offline

Board footer

Powered by FluxBB