By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,331 Members | 1,476 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,331 IT Pros & Developers. It's quick & easy.

Reg: Compiling Problems

100+
P: 105
Hi all,

I am trying to compile a VC++ project and it is win32 console application.When I try to compile it I get a lot of linking problems.I have included all the header files needed for the project..I have no idea of how to solve them as I am little bit new to vc++..Could anyone advice or tell me whats wrong in my program..Here are some of my errors:

(1) error LNK2019: unresolved external symbol "public: __thiscall Parser::Parser(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned short,unsigned short,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Parser@@QAE@V?$basic_string@DU?$char_traits@D@ std@@V?$allocator@D@2@@std@@0000GG00000@Z) referenced in function _main homogenity.obj

(2)error LNK2019: unresolved external symbol "public: void __thiscall Parser::usage(bool)const " (?usage@Parser@@QBEX_N@Z) referenced in function _main homogenity.obj

(3) error LNK2019: unresolved external symbol "public: static void __cdecl GM::close(void)" (?close@GM@@SAXXZ) referenced in function _main homogenity.obj


Thanks a lot in advance.


PS: Here's my Build Log file in case required


Build Log Build started: Project: homogenity, Configuration: Debug|Win32
Command Lines Creating temporary file "d:\ReconAssignments\homogenity\homogenity\Debug\R SP00000333684676.rsp" with contents
[
/OUT:"D:\ReconAssignments\homogenity\Debug\homogeni ty.exe" /INCREMENTAL /MANIFEST /MANIFESTFILE:"Debug\homogenity.exe.intermediate.ma nifest" /DEBUG /PDB:"d:\ReconAssignments\homogenity\debug\homogeni ty.pdb" /SUBSYSTEM:CONSOLE /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

".\Debug\homogenity.obj"

".\Debug\stdafx.obj"

".\Debug\homogenity.res"

".\Debug\homogenity.exe.embed.manifest.res"
]
Creating command line "link.exe @d:\ReconAssignments\homogenity\homogenity\Debug\R SP00000333684676.rsp /NOLOGO /ERRORREPORT:PROMPT"
Output Window Linking...
homogenity.obj : error LNK2019: unresolved external symbol "public: bool __thiscall Parser::parse(int,char * *)" (?parse@Parser@@QAE_NHPAPAD@Z) referenced in function _main
homogenity.obj : error LNK2019: unresolved external symbol "public: static void __cdecl GM::close(void)" (?close@GM@@SAXXZ) referenced in function _main
homogenity.obj : error LNK2019: unresolved external symbol "public: void __thiscall Parser::usage(bool)const " (?usage@Parser@@QBEX_N@Z) referenced in function _main
homogenity.obj : error LNK2019: unresolved external symbol "public: __thiscall Parser::Parser(class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >,unsigned short,unsigned short,class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >)" (??0Parser@@QAE@V?$basic_string@DU?$char_traits@D@ std@@V?$allocator@D@2@@std@@0000GG00000@Z) referenced in function _main
D:\ReconAssignments\homogenity\Debug\homogenity.ex e : fatal error LNK1120: 4 unresolved externals
Results Build log was saved at "file://d:\ReconAssignments\homogenity\homogenity\Debug\Bu ildLog.htm"
homogenity - 5 error(s), 0 warning(s)
Feb 26 '07 #1
Share this Question
Share on Google+
8 Replies


sicarie
Expert Mod 2.5K+
P: 4,677
Hi all,

I am trying to compile a VC++ project and it is win32 console application.When I try to compile it I get a lot of linking problems.I have included all the header files needed for the project..I have no idea of how to solve them as I am little bit new to vc++..Could anyone advice or tell me whats wrong in my program..Here are some of my errors:

(1) error LNK2019: unresolved external symbol "public: __thiscall Parser::Parser(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned short,unsigned short,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Parser@@QAE@V?$basic_string@DU?$char_traits@D@ std@@V?$allocator@D@2@@std@@0000GG00000@Z) referenced in function _main homogenity.obj

(2)error LNK2019: unresolved external symbol "public: void __thiscall Parser::usage(bool)const " (?usage@Parser@@QBEX_N@Z) referenced in function _main homogenity.obj

(3) error LNK2019: unresolved external symbol "public: static void __cdecl GM::close(void)" (?close@GM@@SAXXZ) referenced in function _main homogenity.obj


Thanks a lot in advance.


PS: Here's my Build Log file in case required


Build Log Build started: Project: homogenity, Configuration: Debug|Win32
Command Lines Creating temporary file "d:\ReconAssignments\homogenity\homogenity\Debug\R SP00000333684676.rsp" with contents
[
/OUT:"D:\ReconAssignments\homogenity\Debug\homogeni ty.exe" /INCREMENTAL /MANIFEST /MANIFESTFILE:"Debug\homogenity.exe.intermediate.ma nifest" /DEBUG /PDB:"d:\ReconAssignments\homogenity\debug\homogeni ty.pdb" /SUBSYSTEM:CONSOLE /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

".\Debug\homogenity.obj"

".\Debug\stdafx.obj"

".\Debug\homogenity.res"

".\Debug\homogenity.exe.embed.manifest.res"
]
Creating command line "link.exe @d:\ReconAssignments\homogenity\homogenity\Debug\R SP00000333684676.rsp /NOLOGO /ERRORREPORT:PROMPT"
Output Window Linking...
homogenity.obj : error LNK2019: unresolved external symbol "public: bool __thiscall Parser::parse(int,char * *)" (?parse@Parser@@QAE_NHPAPAD@Z) referenced in function _main
homogenity.obj : error LNK2019: unresolved external symbol "public: static void __cdecl GM::close(void)" (?close@GM@@SAXXZ) referenced in function _main
homogenity.obj : error LNK2019: unresolved external symbol "public: void __thiscall Parser::usage(bool)const " (?usage@Parser@@QBEX_N@Z) referenced in function _main
homogenity.obj : error LNK2019: unresolved external symbol "public: __thiscall Parser::Parser(class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >,unsigned short,unsigned short,class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >)" (??0Parser@@QAE@V?$basic_string@DU?$char_traits@D@ std@@V?$allocator@D@2@@std@@0000GG00000@Z) referenced in function _main
D:\ReconAssignments\homogenity\Debug\homogenity.ex e : fatal error LNK1120: 4 unresolved externals
Results Build log was saved at "file://d:\ReconAssignments\homogenity\homogenity\Debug\Bu ildLog.htm"
homogenity - 5 error(s), 0 warning(s)
Can you post the relevant section of code where this error came from?
Feb 26 '07 #2

100+
P: 105
Hi Sicarie,

Thank you for quick reply..parser.h is the header file already written by somebody...I am thinking its not able to link parser.h file..I am not sure abt it..Any kind of suggestions or help would be great.Thanks.

Here's my code:

Expand|Select|Wrap|Line Numbers
  1. #include "stdafx.h"
  2. #include "parser.h"
  3.  
  4. //int _tmain(int argc, _TCHAR* argv[])
  5. //validate function
  6.  
  7. int main(int argc, char **argv)  //new added
  8. {
  9.  
  10.     Parser *cpar=NULL;
  11.  
  12.          cpar=new Parser("homogenity",
  13.                      "calculate roi",
  14.                      "2007",
  15.                      "e n u is w algo oi ",
  16.          "(e$ n$ u$ [is]$ w$ [algo]$ [oi]$)", iterations,subsets, "","","","","");
  17.  
  18.      if (argc == 1) { cpar->usage(false);            
  19.                       delete cpar;
  20.                       cpar=NULL;
  21.                       GM::close();
  22.                       return(EXIT_SUCCESS);
  23.                     }
  24.      if (!cpar->parse(argc, argv))              
  25.       { delete cpar;
  26.         cpar=NULL;
  27.         GM::close();
  28.         return(-1);
  29.       }
  30.         return 0;
  31. }
Feb 26 '07 #3

Expert 100+
P: 1,510
you are including parser.h at compile time - is there another file parser.cpp (or parser.o or parser.obj) which contains the implementation code of Parser. This would be linked with your code and hopefully the link time errors should go away.
Feb 26 '07 #4

100+
P: 105
Horace1,

Thank you for the suggestion and I will try to do that.Could you please tell me how u link .cpp file to a vc++ project and should I just build my project as usual or should I have to compile all source files included in my project separately ??Thanks.
Feb 26 '07 #5

100+
P: 105
Hi Horace1,

I just wanted to inform you that I have tried to add the .cpp file to my project and also added the header file and it remove my linking errors.Thank you for the solution..But I have been arised with the problem that there existes no stdafx.h in the parser.cpp file I added recently..When I checked in this .cpp file I did not find it..Its giving me fatal error C1010. stdafx.h and .cpp both are included in my actual source project.Thats not a problem, prob is with newly added source file which is read only..

Can you please help me with this..Thanks a lot once again for helping me out.
Feb 26 '07 #6

Expert 100+
P: 1,510
Hi Horace1,

I just wanted to inform you that I have tried to add the .cpp file to my project and also added the header file and it remove my linking errors.Thank you for the solution..But I have been arised with the problem that there existes no stdafx.h in the parser.cpp file I added recently..When I checked in this .cpp file I did not find it..Its giving me fatal error C1010. stdafx.h and .cpp both are included in my actual source project.Thats not a problem, prob is with newly added source file which is read only..

Can you please help me with this..Thanks a lot once again for helping me out.
I don't use vc++ so no idea what is going on - perhaps we have vc++ experts who can assit? You say that parser.cpp is read only - can you change it to full access - if using windows right button click the file in Windows Explorer, click properties and clear the Read Only button.
Feb 26 '07 #7

100+
P: 105
It can be done in that way but I am supposed to use it as it is without making any changes ..I have used Use precompiled header option in the project properties but still gives me the error..

Anyway thank you horace1 for your prompt replies and for your help..

I would appreciate if anyone in the group can help me in this issue.I am stuck at this point.Thanks in advance.
Feb 26 '07 #8

100+
P: 105
Hi all,

I am getting the error LNK:c1010...It says that stdafx.h is not in the source file...Actually I have added a .cpp file to my project which cannot be changed at all as it is defined by somebody and so I cannot include stdafx.h file in it.

But I have included it already in my original .cpp file and have its project properties set to use precompiled header files option so that it could be used to other source files added to my project..I am not sure if I need to change any settings..

Still I am getting the same errror when I build my project..Can anyone please help me how to solve this..I am really stuck at this point..Thank you very much..Look forward to hear from you soon.
Feb 27 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.