473,586 Members | 2,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stupid Linker error LNK2019

6 New Member
I have been googeling every possible solution, but I cannot seem to fix LNK2019. My code is below, but I just cannot understand how anything related to LNK2019 from Microsoft's help center applies to it. GRRRRRR. The error says

1>Lab Four.obj : error LNK2019: unresolved external symbol "void __cdecl highLowReport(c lass weatherStation * const,int)" (?highLowReport @@YAXQAVweather Station@@H@Z) referenced in function _main

1>Lab Four.obj : error LNK2019: unresolved external symbol "void __cdecl dailyReport(cla ss weatherStation * const,int)" (?dailyReport@@ YAXQAVweatherSt ation@@H@Z) referenced in function _main

1>Lab Four.obj : error LNK2019: unresolved external symbol "void __cdecl postTemperature s(class weatherStation * const,int)" (?postTemperatu res@@YAXQAVweat herStation@@H@Z ) referenced in function _main


This is my code...

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class weatherStation  
  6. {
  7.          string stationDesignation;  //Identifies the station
  8.          string stationAgent; //Who's responsible
  9.          double fTemperature; //how hot it is
  10.          double cTemperature;
  11.  
  12. public:
  13.          void setDesignation(string ID)                {stationDesignation = ID;} 
  14.          void setAgent(string agent)                {stationAgent = agent;}
  15.          void setFTemperature(double fDegree)        {fTemperature = fDegree;}
  16.          void setCTemperature(double cDegree)        {cTemperature = cDegree;}
  17.  
  18.          string getDesignation()                {return stationDesignation;}
  19.          string getAgent()                        {return stationAgent;}
  20.          double getTemperature()                {return fTemperature;}
  21.          double getcTemperature()                {return cTemperature;}
  22.  
  23.          void Displayer();
  24.          void postTemperatures(weatherStation list[], int numItems);
  25.          void dailyReport(weatherStation list[], int numItems);
  26.          void highLowReport(weatherStation list[], int numItems);
  27. };
  28. void weatherStation::Displayer() 
  29. {
  30.                  cout << "--------------------------------------" << endl;
  31.                  cout << "Station:\t " << stationDesignation << endl;
  32.                  cout << "Agent:\t  "  << stationAgent << endl;
  33.                  cout << "Current Temperature: " << fTemperature << "\t" << cTemperature << endl;
  34.                  cout << "--------------------------------------" << endl;
  35. }
  36.  
  37. void menu();
  38. int addStations(weatherStation[]);
  39. void postTemperatures(weatherStation[], int);
  40. void dailyReport(weatherStation [], int);
  41. void highLowReport(weatherStation[], int);
  42.  
  43.  
  44.  
  45.  
  46. int main()
  47. {
  48.     weatherStation list[100];
  49.     string command;
  50.     int numItems;
  51.     cout << "Type Menu to view menu";
  52.     for(;;)
  53.     {
  54.         cout << "Enter command: " << endl;
  55.             getline(cin, command);
  56.         if(command == "Menu")
  57.             menu();
  58.         else if(command == "Add Stations")
  59.             numItems = addStations(list);
  60.         else if(command == "Post Temperatures")
  61.             postTemperatures(list, numItems);
  62.         else if(command == "Daily Report")
  63.             dailyReport(list, numItems);
  64.         else if(command == "High-Low Report")
  65.             highLowReport(list, numItems);
  66.         else if(command == "Quit")
  67.             break;
  68.     }
  69. }
  70.  
  71. void menu()
  72. {
  73.     cout << "Menu" << endl;
  74.     cout << "-----------------" << endl;
  75.     cout << "Add Stations" << endl;
  76.     cout << "Post Temperatures" << endl;
  77.     cout << "Daily Report" << endl;
  78.     cout << "High-Low Report" << endl;
  79.     cout << "Quit" << endl;
  80.     cout << "-----------------" << endl;
  81. }
  82.  
  83. int addStations(weatherStation list[])
  84. {
  85.     int K = 0;
  86.     string ID, agent;
  87.     cout << "Enter Station Information Below, Stop To Quit" << endl;
  88.     cout << "-----------------------------------" << endl;
  89.     for(;;)
  90.     {
  91.         cout << "Enter Station Designation: ";
  92.         getline(cin, ID);
  93.         if(ID == "Stop")
  94.             break;
  95.         cout << "Enter Contact Agent: ";
  96.         getline(cin, agent);
  97.         list[K].setDesignation(ID);
  98.         list[K].setAgent(agent);
  99.         K++;
  100.         cout << "-----------------------------------" << endl;
  101.         cout << "-----------------------------------" << endl;
  102.     }
  103.     return K;
  104. }
  105.  
  106. void weatherStation::postTemperatures(weatherStation list[], int numItems)
  107. {
  108.     int A = 0;
  109.     double temperature;
  110.  
  111.     cout << "Enter reported fahrenheit temperatures" << endl;
  112.     cout << endl;
  113.  
  114.     for(A = 0; A < numItems; A++) 
  115.     {
  116.         cout << "Weather Station " << stationDesignation << endl;
  117.         cout << "Agent " << stationAgent << endl;
  118.         cout << "Temperature = ";
  119.         cin >> temperature;
  120.         list[A].setFTemperature(temperature);
  121.         list[A].setCTemperature((5*(temperature-32)/9));
  122.     }
  123.  
  124.     cout << endl;
  125.     cout << "--------------------------------------------------" << endl;
  126. }
  127.  
  128. void weatherStation::dailyReport(weatherStation list[], int numItems)
  129. {
  130.     int A = 0;
  131.     double fTotal = 0;
  132.     double cTotal = 0;
  133.  
  134.     cout << "NGS Daily Temperature Report" << endl;
  135.     cout << "================================================" << endl;
  136.     cout << "\tFahrenheit\tCelsius" << endl;
  137.     cout << "------------------------------------------------" << endl;
  138.     for(A = 0; A < numItems; A++)
  139.     {
  140.         cout << stationDesignation << ": " << fTemperature << "\t" << cTemperature << endl;
  141.         cout << "------------------------------------------------" << endl;
  142.         fTotal += fTemperature;
  143.         cTotal += cTemperature;
  144.     }
  145.     cout << "Mean Temperature: " << fTotal << "\t" << cTotal;
  146.     cout << "================================================" << endl;
  147. }
  148.  
  149. void weatherStation::highLowReport(weatherStation list[], int numItems)
  150. {
  151.     int K = 0;
  152.     double highestF = 0;
  153.     double lowestF = 0;
  154.     double highestC = 0;
  155.     double lowestC = 0;
  156.  
  157.     //Identifying highest and lowest temperatures
  158.     for (K = 0; K < numItems; K++)
  159.     {
  160.         if(fTemperature > highestF)
  161.             highestF = fTemperature;
  162.     }
  163.  
  164.     for (K = 0; K < numItems; K++)
  165.     {
  166.         if(fTemperature < lowestF)
  167.             lowestF = fTemperature;
  168.     }
  169.  
  170.     for (K = 0; K < numItems; K++)
  171.     {
  172.         if(cTemperature > highestC)
  173.             highestC = cTemperature;
  174.     }
  175.  
  176.     for (K = 0; K < numItems; K++)
  177.     {
  178.         if(cTemperature < lowestC)
  179.             highestC = cTemperature;
  180.     }
  181.  
  182.     cout << "NGS High-Low Temperature Report" << endl;
  183.     cout << "===============================================" << endl;
  184.     cout << "\t\t     Fahrenheit" << "\t\tCelsius" << endl;
  185.     cout << "-----------------------------------------------" << endl;
  186.     cout << "Lowest Temperature:  " << lowestF << "\t\t" << lowestC << endl;
  187.     cout << "-----------------------------------------------" << endl;
  188.     cout << "Highest Temperature: " << highestF << "\t\t" << highestC << endl;
  189.     cout << "-----------------------------------------------" << endl;
  190.     cout << "End Temperature Data Report" << endl;
  191. }
  192.  
Jul 26 '09 #1
1 15085
unauthorized
81 New Member
int addStations(wea therStation[]);
void postTemperature s(weatherStatio n[], int);
void dailyReport(wea therStation [], int);
void highLowReport(w eatherStation[], int);

These functions are global declared but not defined. On the other hand your class methods that are defined never get called.

To illustrate my point, look at the following pseudo code:
void my_method(); // let's call this func Fred
class MyClass {
public: void my_method(); // let's call this func Barney
}
MyClass object;
object.my_metho d(); // correct, calls Barney
my_method(); // incorrect - calls Fred

void object::my_meth od() { ... } // defines Barney
void my_method() { ... } // defines Fred

What you are doing instead is just calling the global function, which would normally result in compiler error, but since you have declared yet not defined global function with the same name and params, you get linker errors instead.

If what I'm saying is not clear, you should go read up on some C++ textbook about class methods (also called member functions). Come back if you still have questions after that.
Jul 26 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1681
by: Jim | last post by:
All, I'm trying to debug a Python GPF while running a script that we've written. After fixing up some of the paths for the Python build and successfully building Python from ActiveState source, I compiled the Python Extensions, but am getting the following error:
0
1444
by: KS | last post by:
I am getting linker error for a code that was tested and running. I opened the project in VS.NET 2003 and now i get these errors - I am sure it is some options issue. Can anyone please help? Linking... atls.lib(atlbase.obj) : error LNK2001: unresolved external symbol ___security_cookie PenPacketInfoDlg.obj : error LNK2019: unresolved...
4
4853
by: Eric | last post by:
Hello I receive (only in Release build) the following linker warning: LINK : warning LNK4089: all references to 'WS2_32.dll' discarded by /OPT:REF If I set WS2_32.lib in project properties under ignore specific library, then I receive: ABContainer.obj : error LNK2019: unresolved external symbol
2
3382
by: Senapathy | last post by:
VC++ .NET 2003 Standard Edition Win XP, SP2 Hi, I have a code that builds under VC6.0, but fails to link in VC7.1. The offending code is as follows: _AFX_RICHEDIT_STATE* const pEditState = _afxRichEditState;
3
8057
by: Chucker | last post by:
Hi Folks, I got a Wrapper Dll around a native C++ static library. In .NET 1.1 this worked fine. When moving to .NET 2.0 I get a couple of unresolved externals / linker errors: Error 16 error LNK2028: unresolved token (0A000007) "extern "C" void __clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)"...
0
1747
by: VivekR | last post by:
I have a MFC application developed using VC++ 5. Recently I ported that to VC++ 7.1 and now I am trying to compile the MFC application with /CLR under VC++ 7.1. And I get linker errors referring to one of the libraries that the project uses. Without the /CLR, the project compiles and runs well. There is some library by name task.lib and the...
1
3283
by: developer | last post by:
Hi All I have made a .NET project. the files included are borland c++ files that i am migrate to VC++ .NET I am using Microsoft Visual C++ .NET 2003. the compilation goes through properly, but throws a load of linker errors
1
10346
by: iiitsunny | last post by:
i have ported one project which was working in VC6 to VC7. Now the project is working fine in VC7 also. I have made some additions in VC7 environment only. But the problem is that the project is not working in the release mode. I mean it is shooting off linking errors. I am required to generate an exe file and am looking for some suggestions!!!...
1
4043
bajajv
by: bajajv | last post by:
Hi, While implementing CList class, I got linker errors for constructor and destructor. Below is the code - template<class TYPE, class ARG_TYPE = const TYPE&> class CList { protected: struct CNode { CNode* pNext;
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.