CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2008
    Posts
    11

    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:
    ------------------------------------------
    inline double DegreesToRadians( double Degrees );
    inline double RadiansToDegrees( double Radians );
    --------------------------------------------

    Functions:
    ------------------------------------------
    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:
    -----------------------------------------------------------
    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
    Join Date
    Jun 2006
    Location
    M31
    Posts
    885

    Re: Symbol Referencing Error

    Just a shot in the dark, but this looks suspect:
    Quote Originally Posted by Delpheno
    Code:
    using namespace std;
    
    #include <iostream>
    #include <iomanip>
    #include "proj03.library.h"
    
    #include <cmath>
    
    //...
    Your "using namespace" statement goes after your standard header inclusions.
    Also, next time, please use code tags. Thanks!

  3. #3
    Join Date
    May 2003
    Location
    San Antonio TX
    Posts
    380

    Re: Symbol Referencing Error

    I am assuming the functions:

    inline double DegreesToRadians( double Degrees );
    inline double RadiansToDegrees( double Radians );

    are prototyped inside the "proj03.library.h" header file?

    Are the definitions of the functions inside the same source module as main()?
    John 3:16
    For God so loved the world ...

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured