linking error? I just started learning C++...
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: linking error? I just started learning C++...

Hybrid View

  1. #1
    Join Date
    Jan 2013
    Posts
    2

    linking error? I just started learning C++...

    So I just downloaded DEVc++, just using an example my teacher has given during class to check if it works. Now that it didn't work and I don't know why. I tried to looking for answers about linking error online, but I can't understand the answers.

    So here is the program:

    //Program to convert from Fahrenheit to Celcius
    #include <iostream>

    double fahrenToCelsius (double t);
    //precondition:
    //t is a valid tempreture in Fahrenheit
    //postcondition:
    //returns equivalent temp. in Celcius

    int main ()
    {
    using namespace std;
    double f;

    cout<< "Enter temp. in degrees Fahrenheit. ";
    cin >> f;
    cout<< f << "in degs. Fahrenheit = "
    << fahrenToCelsius (f) << "in degs. Celcius" ;
    cout<<endl;

    return 0;
    }

    double fahrenToCelcius (double t)
    {
    double c;
    c= (t-32.0)*(5.0/9.0);
    return c;
    }


    And here is the problem:
    [Linker error] C:\Users\Owner\AppData\Local\Temp\cckex8SZ.o:fahrenToCelsius.cpp: (.text+0x3d): undefined reference to `fahrenToCelsius(double)'
    collect2: ld returned 1 exit status

    I'm suspecting the program maybe that I saved it wrong? I saved it as fahrentoCelsius.cpp inside the folder "Work" ( I created this folder) which is inside the folder "Dev-cpp".

  2. #2
    Join Date
    Jan 2013
    Posts
    2

    Re: linking error? I just started learning C++...

    Sorry, can someone help me delete this post? I just found out my problem was so simple. Nothing about saving. I just have to put the line using namespace std; right underneath #include<iostream>
    Well, I solved my own problem, sorry about the trouble again!

Tags for this Thread

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center