Thread: Symbol Referencing Error

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    2

    Symbol Referencing Error

    I don't know what I'm doing wrong here. Everything looks okay, but I get a Symbol Referencing Error when I compile.

    Header:
    ------------------------------------------
    Code:
    inline double DegreesToRadians( double Degrees );
    inline double RadiansToDegrees( double Radians );
    --------------------------------------------

    Functions:
    ------------------------------------------
    Code:
    using namespace std;
    
    #include <iostream>
    #include <iomanip>
    #include "proj03.library.h"
    
    #include <cmath>
    
    double DegreesToRadians( double Degrees )
    {
    return Degrees / 180 * 3.1416;
    }
    
    double RadiansToDegrees( double Radians )
    {
    return Radians * 180/3.1416;
    }
    ------------------------------------------------------------

    Main:
    -----------------------------------------------------------
    Code:
    using namespace std;
    
    #include <iostream>
    #include <iomanip>
    #include "proj03.library.h"
    
    int main()
    {
    cout << DegreesToRadians( 45 );
    cout << RadiansToDegrees( 1 );
    }
    ----------------------------------------------------------

    Output:
    ----------------------------------------------------------
    proj03.library.h:1: warning: inline function `double DegreesToRadians(double)' used but never defined
    proj03.library.h:2: warning: inline function `double RadiansToDegrees(double)' used but never defined
    Undefined first referenced
    symbol in file
    DegreesToRadians(double) /var/tmp//ccnvuYnr.o
    RadiansToDegrees(double) /var/tmp//ccnvuYnr.o
    ld: fatal: Symbol referencing errors. No output written to a.out
    collect2: ld returned 1 exit status
    -----------------------------------------------------------------

    WHAT IN THE WORLD IS GOING ON. I've spent hours on this already. If anyone understands what's wrong, please help me.

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    put inline in both the definition and the prototype.

    Oh and if you use inline, you'll have to define it in the header file.
    Last edited by robwhit; 01-31-2008 at 07:51 PM.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    2
    Quote Originally Posted by robwhit View Post
    put inline in both the definition and the prototype.

    Oh and if you use inline, you'll have to define it in the header file.
    Where is the definition and prototype?

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    The definition is the thing with code, the prototype is the thing without code.

    definition
    Code:
    double DegreesToRadians( double Degrees )
    {
    return Degrees / 180 * 3.1416;
    }
    prototype
    Code:
    double DegreesToRadians( double Degrees );

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Getting other processes class names
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2008, 04:02 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  5. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 09:23 PM