C++ solution.. I'm trying to create an project to call another project, so it is supposed to allow me to call the header file from the other project but once i called, there will be the lnk error 2019.
I couldnt understand why it is so.
Initially i thought it was compiler's problem. but slowly i realised, the project cannot be interlinked. any solution out there to assist me in overcoming the problem.
Appreciated the help alot. but it's urgent..
Example :
Created a date proj(which contain datetime.h link with date.h and time.h WORKS FINE) created a power proj - to store float variable only. Created a input proj to store date and power from the two projects above.. but once i declare a Input input; it has the linker problem
Source code as below.. Input.h
#ifndef INPUT_H
#define INPUT_H
//#include "../Date/DateTime.h"
#include "../Power/Power.h"
class Input{
public:
Input();
//{
/*DateTime datetime;
SetDateTime(datetime);*/
//}
friend ostream& operator << (ostream &output, const Input &value);
friend istream & operator>>( istream &input, Input &value );
void SetPower(Power power){
mpower = power;
}
Power GetPower(){
return mpower;
}
//get and set method of variable DateTime
/*void SetDateTime(DateTime datetime);
DateTime GetDateTime();*/
private:
string test;
Power mpower;
//DateTime m_datetime;
};
#endif
input.cpp file
ostream& operator << (ostream &output, const Input &value){
output<<"test";
//<<value.test;
//output<<value.m_datetime<<endl;
return output;
}
istream & operator>>( istream &input, Input &value ){
//input>>value.m_datetime;
return input;
}
Here is the description of the problem (http://msdn.microsoft.com/en-us/library/799kze2z%28v=vs.100%29.aspx) "unresolved external symbol 'symbol' referenced in function 'function'"
And it is exactly what it is. You need to link the library that is actually defining your symbols/objects or where is the implementation. Usually the header files contain only the declaration but the linker, after compiling, also needs your implementation as you are referencing those from your main project (your main project is using those objects). So the linker is unable to link your code.
In VS2010 go to Configuration Properties->Linker->General->Additional Library Directories and specify your library path. Then go to Configuration Properties->Linker->Input->Additional Dependencies and specify the name of the lib (Power.lib ?)
Hope that helps. Let me know if that fixes your issue.