Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LNK2001: unresolved external symbol

Status
Not open for further replies.

jbsys

Programmer
May 6, 2005
51
CA
HI;
I am new to C++, and am having some problems with a dll that I am creating. Most of the fuctions in the dll will be accessible from other programs except for three. I will attempt to explain my problem. I have a function inside of dll project. There is a prototype defined in one of the header files. The function in the dll .cpp program is as follows:

#include "stdafx.h"

int intStrTrmLen(char *strSource,int intLength)
{
// AFX_MANAGE_STATE(AfxGetStaticModuleState());
// char *strSource;
// int intLength;
{
int intCharIndex;
for(intCharIndex=intLength - 1;
intCharIndex > 0 && !isgraph(strSource[intCharIndex]);
intCharIndex--);
return(intCharIndex + 1);
// return TRUE;
}
}


The stdafx.h header file contains the function prototype:
int intStrTrmLen(char,int);


When I attempt to build or rebuild my project, I get the error LNK2001: unresolved external symbol "int __cdecl intStrTrmLen(char,int)" (?intStrTrmLen@@YAHDH@Z) error. Does anyone have any ideas as to;
1) How does this occur?
2) What do I do to fix it?

Thanks
jbsys
 
carefully. you missed a * in the prototype.

the prototype should be:
int intStrTrmLen(char*,int);

One more thing. Do not put common used functions in stdafx.h file directly. Instead put all in a file like common.h then add an include <common.h> call. This way, the code is more modular and easy to reuse.

s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top