Board index » Visual Studio » error LNK2001

error LNK2001

Visual Studio313
My current issue..I can not link. I have my current project compiled

and I looked at msdn library about the issue but I don't see what I

could be doing wrong. The pathpoint object calls the leg object and

the leg object is the bottom object (from an hierarchy perspective) and

everything else builds from this. And there are a total of 4 modules

that use the variables, while only pathpoint is the only one that uses

the function calls. The variables are gpcField, gfHiRange,

gfLoRange, and gfResolution.



Linking...

pathpoint.obj : error LNK2001: unresolved external symbol "public:

__thiscall CLeg::CLeg(class CString const

&,int,double,double,double,char const *,enum DATA_CONTENT_TYPE)"

(??0CLeg@@QAE@ABVCString@@HNNNPBDW4DATA_CONTENT_TYPE@@@Z)

pathpoint.obj : error LNK2001: unresolved external symbol "char * *

gpcField" (?gpcField@@3PAPADA)

pathpoint.obj : error LNK2001: unresolved external symbol "public: void

__thiscall CLeg::Reset(class CString const &)"

(?Reset@CLeg@@QAEXABVCString@@@Z)

pathpoint.obj : error LNK2001: unresolved external symbol "public: void

__thiscall CLeg::SetValue(class CString const &,int)"

(?SetValue@CLeg@@QAEXABVCString@@H@Z)

pathpoint.obj : error LNK2001: unresolved external symbol "public: void

__thiscall CLeg::SetValue(double,int)" (?SetValue@CLeg@@QAEXNH@Z)

pathpoint.obj : error LNK2001: unresolved external symbol "public: int

__thiscall CLeg::IsValid(class CString const &,class CString &)const "

(?IsValid@CLeg@@QBEHABVCString@@AAV2@@Z)

pathpoint.obj : error LNK2001: unresolved external symbol "double const

* const gfHiRange" (?gfHiRange@@3QBNB)

pathpoint.obj : error LNK2001: unresolved external symbol "double const

* const gfLoRange" (?gfLoRange@@3QBNB)

pathpoint.obj : error LNK2001: unresolved external symbol "public: void

__thiscall CLeg::UpdateEntry(class CString const &,int)"

(?UpdateEntry@CLeg@@QAEXABVCString@@H@Z)

pathpoint.obj : error LNK2001: unresolved external symbol "double const

* const gfResolution" (?gfResolution@@3QBNB)



any help is more than appreciated.



thanks


-
 

Re:error LNK2001

Kman wrote:

Quote
My current issue..I can not link. I have my current project compiled

and I looked at msdn library about the issue but I don't see what I

could be doing wrong.

[...]

Linking...

pathpoint.obj : error LNK2001: unresolved external symbol "public:

__thiscall CLeg::CLeg(class CString const

&,int,double,double,double,char const *,enum DATA_CONTENT_TYPE)"

(??0CLeg@@QAE@ABVCString@@HNNNPBDW4DATA_CONTENT_TYPE@@@Z)

pathpoint.obj : error LNK2001: unresolved external symbol "char * *

gpcField" (?gpcField@@3PAPADA)



Did you do exactly as Igor told you to do, i.e. the declaration in the

headers and the definition in exactly one sourcefile? How about providing a

minimal example as is customary?



Uli



-

Re:error LNK2001

Yes i did, my previous error was LNK2005, this one is LNK2001. So I do

not think they are related issues, but maybe. I am not sure how much

of an example I can supply but here goes.



//Pathpoint.cpp

#include "stdafx.h"

#include <Math.h>//maybe used in RoundOffEntry

#include "DataBlock.h"

#include "PathPoint.h"

#include "Leg.h"

#include "resource.h"



#ifdef _DEBUG

#undef THIS_FILE

static char THIS_FILE[]=__FILE__;

#define new DEBUG_NEW

#endif



//////////////////////////////////////////////////////////////////////

// Construction/Destruction

//////////////////////////////////////////////////////////////////////



const BYTE CPathPoint::m_bySPARE = 0x00; //Spare byte (used with mask)



CPathPoint::CPathPoint()

{

//ASSERT( FALSE ); // This constrcutor is not to be used

}



CPathPoint::CPathPoint( const CString &strFieldName, int nBitsUsed,

double fLoRange,

double fHiRange, double fResolution, LPCTSTR lpstrUnit /*= "N/A"

*/, DATA_CONTENT_TYPE eDataContentType /*= EDITABLE*/ )

{

m_strFieldName = strFieldName;

m_nBitsUsed = nBitsUsed,

m_fLoRange = fLoRange;

m_fHiRange = fHiRange;

m_fResolution = fResolution;

m_strUnit = lpstrUnit;

m_eDataContentType = eDataContentType;

m_oLegInfo = NULL;



for( int i = 13; i <= 20; i++ )

{

if( m_strFieldName == gpcField[ i ] )

{

m_oLegInfo = new CLeg( strFieldName,

nBitsUsed,

fLoRange,

fHiRange,

fResolution,

lpstrUnit,

eDataContentType );

break;

}

}

}



//There is a lot more to this code but Pathpoint calls all the

functions that show up as an issue on linking.

//but not all the functions called by Pathpoint which reference a

function in Leg.h give errors only those that

//are not inline of the Leg.h get errors



thanks,

Kman



-

Re:error LNK2001

Kman wrote:

[snipped example]



Something must be seriously messed up with your system if every single line

of that large and incomplete example is necessary to demonstrate the

problem. Otherwise, and I think that is the case, you did miss the required

attribute 'minimal'. It means that you (yes you!) remove everything that is

not required to demonstrate the problem.



BTW: just reposting your message is only getting you added to killfiles, it

is not getting you answers faster.



Uli





-

Re:error LNK2001

Well obviously you are a little annoyed, that definetly is not what I

am trying to do...but you don't have to be rude about it. I put in the

linking error that I get...and there is no error with the compiling at

all. There is nothing besides the link error that I have posted that

points to anywhere in the code. So I am sorry if you think there is

some code that I could just put up there that shows where it goes

wrong. And the reposting was an accident I thought it did not send.

So I don't know how to demonstrate the problem with out giving you all

the files and allow you to build the project yourself.



kman



-

Re:error LNK2001

Quote
Well obviously you are a little annoyed, that definetly is not what I

am trying to do...



Irritation has nothing to do with it.

If a programmer is trying to demonstrate a problem, he/she needs to



1) post a _COMPLETE_ example

2) post a _MINIMAL_ example

3) Any compilation switches

4) Any linker switches

5) Versions of the compiler + service pack



Frequently trying to demostrate the problem may suggest the solution to

yourself.



Quote
So I am sorry if you think there is

some code that I could just put up there that shows where it goes

wrong. And the reposting was an accident I thought it did not send.

So I don't know how to demonstrate the problem with out giving you all

the files and allow you to build the project yourself.



Well link failure is fairly easy to find:



1) You do have defined the constructor CLeg::CLeg (not declared -actually

defined)?

2) You are linking the module it is defined in?



Stephen Howe





-

Re:error LNK2001

Well as a start, make sure you are *defining* all versions of these

functions:

CLeg::CLeg(), CLeg::Reset(), CLeg::SetValue(), CLeg::IsValid(),

CLeg::UpdateEntry()



Also make sure to *define* these variables:

double const* const gfHiRange;

double const* const gfLoRange;

double const* const gfResolution



In exactly one cpp (As Igor suggested)



Or, if you're using an external library for that CLeg class, make sure to

link to it...



BTW: I think posting the header of CLeg would be much more useful...



Hope that helped,

Abdo Haji-Ali

Programmer

In|Framez



"Kman" <kman_l@yahoo.com>wrote in message

Quote
My current issue..I can not link. I have my current project compiled

and I looked at msdn library about the issue but I don't see what I

could be doing wrong. The pathpoint object calls the leg object and

the leg object is the bottom object (from an hierarchy perspective) and

everything else builds from this. And there are a total of 4 modules

that use the variables, while only pathpoint is the only one that uses

the function calls. The variables are gpcField, gfHiRange,

gfLoRange, and gfResolution.



Linking...

pathpoint.obj : error LNK2001: unresolved external symbol "public:

__thiscall CLeg::CLeg(class CString const

&,int,double,double,double,char const *,enum DATA_CONTENT_TYPE)"

(??0CLeg@@QAE@ABVCString@@HNNNPBDW4DATA_CONTENT_TYPE@@@Z)

pathpoint.obj : error LNK2001: unresolved external symbol "char * *

gpcField" (?gpcField@@3PAPADA)

pathpoint.obj : error LNK2001: unresolved external symbol "public: void

__thiscall CLeg::Reset(class CString const &)"

(?Reset@CLeg@@QAEXABVCString@@@Z)

pathpoint.obj : error LNK2001: unresolved external symbol "public: void

__thiscall CLeg::SetValue(class CString const &,int)"

(?SetValue@CLeg@@QAEXABVCString@@H@Z)

pathpoint.obj : error LNK2001: unresolved external symbol "public: void

__thiscall CLeg::SetValue(double,int)" (?SetValue@CLeg@@QAEXNH@Z)

pathpoint.obj : error LNK2001: unresolved external symbol "public: int

__thiscall CLeg::IsValid(class CString const &,class CString &)const "

(?IsValid@CLeg@@QBEHABVCString@@AAV2@@Z)

pathpoint.obj : error LNK2001: unresolved external symbol "double const

* const gfHiRange" (?gfHiRange@@3QBNB)

pathpoint.obj : error LNK2001: unresolved external symbol "double const

* const gfLoRange" (?gfLoRange@@3QBNB)

pathpoint.obj : error LNK2001: unresolved external symbol "public: void

__thiscall CLeg::UpdateEntry(class CString const &,int)"

(?UpdateEntry@CLeg@@QAEXABVCString@@H@Z)

pathpoint.obj : error LNK2001: unresolved external symbol "double const

* const gfResolution" (?gfResolution@@3QBNB)



any help is more than appreciated.



thanks







-

Re:error LNK2001

Thanks for all the help. I finally figured it out. Since I have such

a big program, I did not realize that I had included the pathpoint.cpp

file and its header in the project other then the one I was working on.

There are about 14 projects and one major one that depends on the

other 13 projects. So my workspace is quite huge. So there was

nothing wrong with my code but the code itself was being referenced in

a different project that it should not have been in. I appreciate all

the help though. Hopefully we are all on good terms.



-