Reg: Compiling Problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mickey22
    New Member
    • Feb 2007
    • 105

    Reg: Compiling Problems

    Hi all,

    I am trying to compile a VC++ project and it is win32 console application.Whe n 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_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,unsigned short,unsigned short,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >)" (??0Parser@@QAE @V?$basic_strin g@DU?$char_trai ts@D@std@@V?$al locator@D@2@@st d@@0000GG00000@ Z) referenced in function _main homogenity.obj

    (2)error LNK2019: unresolved external symbol "public: void __thiscall Parser::usage(b ool)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@@SAX XZ) 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:\ReconAssign ments\homogenit y\homogenity\De bug\RSP00000333 684676.rsp" with contents
    [
    /OUT:"D:\ReconAs signments\homog enity\Debug\hom ogenity.exe" /INCREMENTAL /MANIFEST /MANIFESTFILE:"D ebug\homogenity .exe.intermedia te.manifest" /DEBUG /PDB:"d:\ReconAs signments\homog enity\debug\hom ogenity.pdb" /SUBSYSTEM:CONSO LE /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\homoge nity.obj"

    ".\Debug\stdafx .obj"

    ".\Debug\homoge nity.res"

    ".\Debug\homoge nity.exe.embed. manifest.res"
    ]
    Creating command line "link.exe @d:\ReconAssign ments\homogenit y\homogenity\De bug\RSP00000333 684676.rsp /NOLOGO /ERRORREPORT:PRO MPT"
    Output Window Linking...
    homogenity.obj : error LNK2019: unresolved external symbol "public: bool __thiscall Parser::parse(i nt,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@@SAX XZ) referenced in function _main
    homogenity.obj : error LNK2019: unresolved external symbol "public: void __thiscall Parser::usage(b ool)const " (?usage@Parser@ @QBEX_N@Z) referenced in function _main
    homogenity.obj : error LNK2019: unresolved external symbol "public: __thiscall Parser::Parser( class std::basic_stri ng,class std::allocator >,class std::basic_stri ng,class std::allocator >,class std::basic_stri ng,class std::allocator >,class std::basic_stri ng,class std::allocator >,class std::basic_stri ng,class std::allocator >,unsigned short,unsigned short,class std::basic_stri ng,class std::allocator >,class std::basic_stri ng,class std::allocator >,class std::basic_stri ng,class std::allocator >,class std::basic_stri ng,class std::allocator >,class std::basic_stri ng,class std::allocator >)" (??0Parser@@QAE @V?$basic_strin g@DU?$char_trai ts@D@std@@V?$al locator@D@2@@st d@@0000GG00000@ Z) referenced in function _main
    D:\ReconAssignm ents\homogenity \Debug\homogeni ty.exe : fatal error LNK1120: 4 unresolved externals
    Results Build log was saved at "file://d:\ReconAssignm ents\homogenity \homogenity\Deb ug\BuildLog.htm "
    homogenity - 5 error(s), 0 warning(s)
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Originally posted by mickey22
    Hi all,

    I am trying to compile a VC++ project and it is win32 console application.Whe n 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_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,unsigned short,unsigned short,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >)" (??0Parser@@QAE @V?$basic_strin g@DU?$char_trai ts@D@std@@V?$al locator@D@2@@st d@@0000GG00000@ Z) referenced in function _main homogenity.obj

    (2)error LNK2019: unresolved external symbol "public: void __thiscall Parser::usage(b ool)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@@SAX XZ) 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:\ReconAssign ments\homogenit y\homogenity\De bug\RSP00000333 684676.rsp" with contents
    [
    /OUT:"D:\ReconAs signments\homog enity\Debug\hom ogenity.exe" /INCREMENTAL /MANIFEST /MANIFESTFILE:"D ebug\homogenity .exe.intermedia te.manifest" /DEBUG /PDB:"d:\ReconAs signments\homog enity\debug\hom ogenity.pdb" /SUBSYSTEM:CONSO LE /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\homoge nity.obj"

    ".\Debug\stdafx .obj"

    ".\Debug\homoge nity.res"

    ".\Debug\homoge nity.exe.embed. manifest.res"
    ]
    Creating command line "link.exe @d:\ReconAssign ments\homogenit y\homogenity\De bug\RSP00000333 684676.rsp /NOLOGO /ERRORREPORT:PRO MPT"
    Output Window Linking...
    homogenity.obj : error LNK2019: unresolved external symbol "public: bool __thiscall Parser::parse(i nt,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@@SAX XZ) referenced in function _main
    homogenity.obj : error LNK2019: unresolved external symbol "public: void __thiscall Parser::usage(b ool)const " (?usage@Parser@ @QBEX_N@Z) referenced in function _main
    homogenity.obj : error LNK2019: unresolved external symbol "public: __thiscall Parser::Parser( class std::basic_stri ng,class std::allocator >,class std::basic_stri ng,class std::allocator >,class std::basic_stri ng,class std::allocator >,class std::basic_stri ng,class std::allocator >,class std::basic_stri ng,class std::allocator >,unsigned short,unsigned short,class std::basic_stri ng,class std::allocator >,class std::basic_stri ng,class std::allocator >,class std::basic_stri ng,class std::allocator >,class std::basic_stri ng,class std::allocator >,class std::basic_stri ng,class std::allocator >)" (??0Parser@@QAE @V?$basic_strin g@DU?$char_trai ts@D@std@@V?$al locator@D@2@@st d@@0000GG00000@ Z) referenced in function _main
    D:\ReconAssignm ents\homogenity \Debug\homogeni ty.exe : fatal error LNK1120: 4 unresolved externals
    Results Build log was saved at "file://d:\ReconAssignm ents\homogenity \homogenity\Deb ug\BuildLog.htm "
    homogenity - 5 error(s), 0 warning(s)
    Can you post the relevant section of code where this error came from?

    Comment

    • mickey22
      New Member
      • Feb 2007
      • 105

      #3
      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:

      Code:
      #include "stdafx.h"
      #include "parser.h"
      
      //int _tmain(int argc, _TCHAR* argv[])
      //validate function
      
      int main(int argc, char **argv)  //new added
      {
      
      	Parser *cpar=NULL;
                                                               
      	     cpar=new Parser("homogenity",
                           "calculate roi",
                           "2007",
                           "e n u is w algo oi ",
      	     "(e$ n$ u$ [is]$ w$ [algo]$ [oi]$)", iterations,subsets, "","","","","");
      
      	 if (argc == 1) { cpar->usage(false);            
                            delete cpar;
                            cpar=NULL;
                            GM::close();
                            return(EXIT_SUCCESS);
                          }
           if (!cpar->parse(argc, argv))              
            { delete cpar;
              cpar=NULL;
              GM::close();
              return(-1);
            }
          	return 0;
      }

      Comment

      • horace1
        Recognized Expert Top Contributor
        • Nov 2006
        • 1510

        #4
        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.

        Comment

        • mickey22
          New Member
          • Feb 2007
          • 105

          #5
          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.
          Last edited by mickey22; Feb 26 '07, 05:14 PM. Reason: Few more questions

          Comment

          • mickey22
            New Member
            • Feb 2007
            • 105

            #6
            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.

            Comment

            • horace1
              Recognized Expert Top Contributor
              • Nov 2006
              • 1510

              #7
              Originally posted by mickey22
              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.

              Comment

              • mickey22
                New Member
                • Feb 2007
                • 105

                #8
                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.

                Comment

                • mickey22
                  New Member
                  • Feb 2007
                  • 105

                  #9
                  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.

                  Comment

                  Working...