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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error LNK2019: unresolved external symbol 1

Status
Not open for further replies.

jamez05

Programmer
Jul 29, 2005
130
US
I'm new to C/C++ and trying to port a Unix C program to Windows C++. The old version used getopt() for command line processing. I replaced this function with cout and cin and my main page now looks like this:

int main()
{

struct chemical chem; /* one and only chemical for this program */

/* prototypes */

void resmi(char *,int);
int setatomgr(struct chemical *);
void tcosmi(char *,int);

char redone[SMLN+1];
char unique[SMLN+1];
char *temp;
char SmilesString[5];
int result;
int i;

/* preset strings to zero, since we don't
* know where the terminators are going
* to occur
*/
for (i = 0 ; i <= SMLN ; i++) {
redone = '\0';
unique = '\0';
}
cout<<"Please enter a SMILES string: ";
cin>> SmilesString;
cin.ignore();
if (strlen(SmilesString)> NMLN - 1) {
cout <<"Length of input string is too long\n";
exit(1);
}
temp = SmilesString;
strcpy(chem.name,temp);
strcpy(chem.smiles,temp);
chem.seqnum = 1; /* one and only chemical for this program to process */
result = setatomgr(&chem);
if (result) {
resmi(redone,SMLN);
tcosmi(unique,SMLN);
printf("%s\n",unique);
}
return(!result);
}

I get the following warnings and errors when I try to compile it:

Compiling...
aaunique.cpp
c:\documents and settings\epajn\my documents\visual studio 2005\projects\aaunique\aaunique\aaunique.cpp(49) : warning C4996: 'strcpy' was declared deprecated c:\program files\microsoft visual studio 8\vc\include\string.h(56) : see declaration of 'strcpy'

c:\documents and settings\epajn\my documents\visual studio 2005\projects\aaunique\aaunique\aaunique.cpp(50) : warning C4996: 'strcpy' was declared deprecated c:\program files\microsoft visual studio 8\vc\include\string.h(56) : see declaration of 'strcpy'

Compiling manifest to resources...
Linking...
aaunique.obj : error LNK2019: unresolved external symbol "void __cdecl tcosmi(char *,int)" (?tcosmi@@YAXPADH@Z) referenced in function _main

aaunique.obj : error LNK2019: unresolved external symbol "void __cdecl resmi(char *,int)" (?resmi@@YAXPADH@Z) referenced in function _main
aaunique.obj : error LNK2019: unresolved external symbol "int __cdecl setatomgr(struct chemical *)" (?setatomgr@@YAHPAUchemical@@@Z) referenced in function _main

Debug\aaunique.exe : fatal error LNK1120: 3 unresolved externals

I'm not sure if the warnings have anything to do with the linking errors, but thought I should include them. Here
is the line of code that produces the error in string.h:

__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1(char *, __RETURN_POLICY_DST, __EMPTY_DECLSPEC, strcpy, __out_z char, _Dest, __in_z const char *, _Source)

I'm not sure what I'm really doing, so any help would be greatly appreciated

Thanks

James
 
Microsoft deprecated strcpy in their latest compiler because it is more dangerous than most functions. It should still work so you can ignore those warnings if you want. Or you can listen to the warning and change to something other than strcpy. I believe the new, safer version is strcpy_s, but in my opinion you should just switch to C++ strings if you choose to update your code.

The linker errors are not related to the warnings and are there because you prototype those three functions, resmi, setatomgr and tcosmi, but the linker cannot find the implementation of them. Where are they implemented? Did you remember to add any other files you are using to the project?
 
Thanks, your information has pointed me in the right direction. I won't be able to post my findings for a couple of days because they have another project that I need to try to figure out right away.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top