CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2013

    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);
    //t is a valid tempreture in Fahrenheit
    //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" ;

    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

    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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.