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
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