Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: undefined reference

  1. #1

    undefined reference

    I am trying to run a program : http://ogldev.atspace.co.uk/www/tuto...utorial16.html

    However, I get undefined reference to some function mentioned below, which is weird, because all those function and their headers are included in the tutorial source.

    g++ tutorial16.cpp -lGLEW -lGL -lglut -I/usr/include/ImageMagick/
    Code :
    /tmp/ccsp9wYo.o: In function `RenderSceneCB()':
    tutorial16.cpp:(.text+0x14): undefined reference to `Camera::OnRender()'
    tutorial16.cpp:(.text+0x128): undefined reference to `Pipeline::GetTrans()'
    tutorial16.cpp:(.text+0x215): undefined reference to `Texture::Bind(unsigned int)'
    /tmp/ccsp9wYo.o: In function `SpecialKeyboardCB(int, int, int)':
    tutorial16.cpp:(.text+0x27e): undefined reference to `Camera::OnKeyboard(int)'
    /tmp/ccsp9wYo.o: In function `PassiveMouseCB(int, int)':
    tutorial16.cpp:(.text+0x2bd): undefined reference to `Camera::OnMouse(int, int)'
    /tmp/ccsp9wYo.o: In function `main':
    tutorial16.cpp:(.text+0xa9b): undefined reference to `Camera::Camera(int, int)'
    tutorial16.cpp:(.text+0xba3): undefined reference to `Texture::Texture(unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
    tutorial16.cpp:(.text+0xbce): undefined reference to `Texture::Load()'
    collect2: ld returned 1 exit status

    This is very weird, Can anyone running Linux do me a favor to try to run this program, I want to see where the problem comes from.

    (Don't forget to install libMagick with apt-get install libmagick++-dev)

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    790
    While you run into this problem while doing OpenGL programming, it is not an OpenGL related problem (so better place to ask would be a general C/C++ programming forum, where folks are likely to point you to resources how the compilation/link process works). Headers only make variable and function declarations known to the compiler, it will then happily generate code using those declarations assuming you will provide the corresponding definitions at link time. You probably need to link with a utility library that is part of the tutorial and contains those definitions.

    Does that tutorial not have a build system that builds executables for you and takes care of supplying the correct compiler and linker command line arguments?

  3. #3
    Yes, it was a link and compile problem. I did not compile & link all cpp files included in main CPP file. THanks for the hint.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •