C++ LNK 2019 from different project but in the same solution

Go To StackoverFlow.com

0

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;
}
2012-04-05 19:06
by JoyceLim


0

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.

2012-04-05 19:20
by ervinbosenbacher
The problem you mention was right. but the solution doesnt seemed correct - JoyceLim 2012-04-06 07:10
i cant locate the library file - JoyceLim 2012-04-06 07:11
Thanks. Where you can find the Power.h that is your source code and if you haven't modified the Power solution's standard compiler parameters it should be in your Debug or Release folder whichever build you have done. And you need to reference that folder. Alternatively if you have the power.h in your visual studio you can right click on the top of your window where the name is and then select open file location or copy full path and there you have it, you just need to go up one level and then to Debug folder, then copy it into your settings. Let me know how you getting on - ervinbosenbacher 2012-04-06 14:01
Or you can search for it in the windows explorer window - ervinbosenbacher 2012-04-06 14:03
Ads