Results 1 to 3 of 3

Thread: Undefined reference problem

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2011

    Undefined reference problem

    Hey guys, i keep getting this error, it displays
    Undefined Reference to 'BackgroundSystem::draw()'
    now im working on a project with 4 other people, so we are using it to "pull" and "push", now when i add a new source file (BackgroundSystem.cpp) i have to add it to the makefile manually, so i do, but when i go to compile it just prints out undefined reference, i have checked the header files and source files way to many times for me to remember, and i cant see anything wrong,
    does anyone have any idea on why this is happening?


  2. #2
    Newbie Frequent Contributor
    Join Date
    Mar 2016

    Re: Undefined reference problem

    The error is from the linker, not the compiler.

    Your header declares a member function draw() in class BackgroundSystem. The compiler will be happy to generate calls to that member function in the assumption that at link time one of the .o files (or libraries) in the link will provide that function. None does, so you get an undefined reference error.

    Have you defined BackgroundSystem::draw() in your .cpp, i.e. have you written that function's body?

  3. #3
    Senior Member Regular Contributor
    Join Date
    Jun 2009
    FL , USA

    Re: Undefined reference problem

    Your question is for general coding rather than OpenGL.
    But to answer your question, this looks like a linker error.

    Check that the name of function is correct.
    Also look at the declaration. The error is due to the linker not getting access to the function definition.

    Inspect the path settings - the lib and include files.

Similar Threads

  1. undefined reference
    By hcdoeko in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-09-2014, 12:34 PM
  2. undefined reference
    By saman_artorious in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 08-16-2013, 11:49 PM
  3. undefined reference
    By mili123 in forum OpenGL: Windows
    Replies: 3
    Last Post: 12-21-2009, 09:45 PM
  4. Getting undefined reference to
    By in forum OpenGL: Linux
    Replies: 1
    Last Post: 02-26-2003, 10:01 AM
  5. undefined reference to gl everything
    By in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-24-2000, 12:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean