Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: undefined reference to `gluPerspective'  (Read 17215 times)

0 Members and 2 Guests are viewing this topic.

Gmaj7

  • Newbie
  • *
  • Posts: 3
    • View Profile
undefined reference to `gluPerspective'
« on: November 27, 2009, 03:29:41 pm »
I tried this tutorial

http://www.sfml-dev.org/tutorials/1.5/window-opengl.php

and somehow it showed this error message:
Quote
/home/hmh/Cpp/TEST-SFML/main.cpp|35|undefined reference to `gluPerspective'|


although as it says
Quote
To use OpenGL, you only have to include Window.hpp


I'm using Code::Blocks.. Ubuntu..

Thanks.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
undefined reference to `gluPerspective'
« Reply #1 on: November 27, 2009, 04:47:44 pm »
You have to link to glu32.a.
Laurent Gomila - SFML developer

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
undefined reference to `gluPerspective'
« Reply #2 on: November 27, 2009, 06:53:27 pm »
Laurent, maybe you should include this info in the tutorials.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
undefined reference to `gluPerspective'
« Reply #3 on: November 28, 2009, 02:10:08 am »
I agree :)
Laurent Gomila - SFML developer

Gmaj7

  • Newbie
  • *
  • Posts: 3
    • View Profile
undefined reference to `gluPerspective'
« Reply #4 on: November 28, 2009, 01:03:36 pm »
So what should I do?  :? I tried adding -lopengl32 -lglu32 , it couldnt find those, then tried searching for glu32.a , apparently there is no such a file on system..

Thanks.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
undefined reference to `gluPerspective'
« Reply #5 on: November 28, 2009, 01:31:21 pm »
You have to get the corresponding packets.

I don't know the way to download it, maybe other users know.

musicman3569

  • Newbie
  • *
  • Posts: 1
    • View Profile
Ubuntu Packages
« Reply #6 on: January 02, 2010, 12:13:16 am »
I just got the example working after some struggling.  I am on Ubuntu 9.10 64-bit.

I installed (in synaptic):
libgl1-mesa-dev
libglu1-mesa-dev
libopenal-dev

I think that was all I needed to add.  For those who don't know, if you need to find what files a package adds, just look for the package in Synaptic, right-click, go to Properties, and click on the Installed Files tab.  You can see exactly where it puts everything (including the glu.h and glu32.a in this case) -- nice, eh?

Then, for the compiler in your IDE (or if you do it manually) you need to add /usr/include/GL.  You would add "-l/usr/lib/GL" to your g++ compile options if you're doing it from the command line.

For the linker, you need to link with /usr/lib/libGLU.a and /usr/lib/libGLU.so.  To do this add "-L/usr/lib -lGLU" to your linking options, or if your IDE supports it, just select the above mentioned files wherever it asks you for what libraries to use.

I hope this helps!

bobl

  • Newbie
  • *
  • Posts: 18
    • View Profile
undefined reference to `gluPerspective'
« Reply #7 on: February 08, 2010, 09:44:11 pm »
I too am having problems with this tutorial on amd64/linux

I already had the latest versions of the 3 files that you suggest downloading.

I tried your suggestions in various configurations, one of which was...

g++ -c window-opengl.cpp -lsfml-graphics -lsfml-window -lsfml-system -l/usr/lib/GL

g++ -o window-opengl window-opengl.o -L/usr/lib -lGLU

I'm not sure if that's what you meant but none of them have worked.

The first line produces the .o file
The second line produces this

window-opengl.o: In function `main':
window-opengl.cpp:(.text+0x55): undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
window-opengl.cpp:(.text+0x79): undefined reference to `sf::Window::Window(sf::VideoMode, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, sf::WindowSettings const&)'
window-opengl.cpp:(.text+0xea): undefined reference to `sf::Clock::Clock()'
window-opengl.cpp:(.text+0x114): undefined reference to `sf::Window::~Window()'
window-opengl.cpp:(.text+0x1f5): undefined reference to `sf::Window::Close()'
window-opengl.cpp:(.text+0x213): undefined reference to `sf::Window::Close()'
window-opengl.cpp:(.text+0x244): undefined reference to `sf::Window::GetEvent(sf::Event&)'
window-opengl.cpp:(.text+0x259): undefined reference to `sf::Window::SetActive(bool) const'
window-opengl.cpp:(.text+0x28e): undefined reference to `sf::Clock::GetElapsedTime() const'
window-opengl.cpp:(.text+0x2b6): undefined reference to `sf::Clock::GetElapsedTime() const'
window-opengl.cpp:(.text+0x2de): undefined reference to `sf::Clock::GetElapsedTime() const'
window-opengl.cpp:(.text+0x5d0): undefined reference to `sf::Window::Display()'
window-opengl.cpp:(.text+0x5dc): undefined reference to `sf::Window::IsOpened() const'
window-opengl.cpp:(.text+0x5f5): undefined reference to `sf::Window::~Window()'
window-opengl.cpp:(.text+0x62b): undefined reference to `sf::Window::~Window()'

I tried commenting out the gluPerspective line
and it all compiled nicely with
g++ -o window-opengl window-opengl.cpp -lsfml-graphics -lsfml-window -lsfml-system

and ran as a window so it does seem to be this bit that is doing the "damage"

==============================================

Your synaptic suggestion is excellent 'cos I've never known how to look at what gets put where. Synaptic shows that my files are here...

libgl1-mesa-dev contains...
================
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libgl1-mesa-dev
/usr/share/doc/libgl1-mesa-dev/copyright
/usr/share/doc/libgl1-mesa-dev/changelog.Debian.gz
/usr/lib
/usr/lib/pkgconfig
/usr/lib/pkgconfig/gl.pc
/usr/lib/libGL.so

libglu1-mesa-dev contains...
=================
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libglu1-mesa-dev
/usr/share/doc/libglu1-mesa-dev/copyright
/usr/share/doc/libglu1-mesa-dev/changelog.Debian.gz
/usr/include
/usr/include/GL
/usr/include/GL/glu.h
/usr/include/GL/glu_mangle.h
/usr/lib
/usr/lib/libGLU.a
/usr/lib/libGLU.so


and libopenal-dev contains...
=================
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libopenal-dev
/usr/share/doc/libopenal-dev/README.Debian
/usr/share/doc/libopenal-dev/copyright
/usr/share/doc/libopenal-dev/changelog.Debian.gz
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/openal-config.1.gz
/usr/include
/usr/include/AL
/usr/include/AL/al.h
/usr/include/AL/alc.h
/usr/include/AL/alext.h
/usr/lib
/usr/lib/libopenal.a
/usr/lib/pkgconfig
/usr/lib/pkgconfig/openal.pc
/usr/bin
/usr/bin/openal-config
/usr/lib/libopenal.so

Could someone please advise
a) whether I've got all the files this tutorial needs and
b) what my compile line should be

To give some idea of the state of my system
I was able to compile and run this example
   http://www.sfml-dev.org/tutorials/1.4/graphics-fonts.php
with
   g++ -o graphics-fonts graphics-fonts.cpp -lsfml-graphics -lsfml-window -lsfml-system
Hope this helps

Thx in anticipation

bobl

  • Newbie
  • *
  • Posts: 18
    • View Profile
undefined reference to `gluPerspective'
« Reply #8 on: February 08, 2010, 10:29:13 pm »
The answer was staring me in the face in the 1.5 sdk opengl makefile sample.

g++ -o window-opengl window-opengl.cpp -lsfml-graphics -lsfml-window -lsfml-system -lGLU -lGL

Thank you Laurent!