dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Link error- unresolved external symbols

  1. #1
    Join Date
    Oct 2000
    Posts
    21

    Link error- unresolved external symbols

    I'm having some link error problems. Originally I was getting link errors involving the nafxcw.lib and libc.lib(150 errors!!!). The nafxcw.lib seemed to be clobbering symbols in mfc42.dll. I told the linker to ignore nafxcw.lib and libc.lib. Now I'm down to 15 errors:

    Common.lib(SocketThread.obj) : error LNK2001: unresolved external symbol "protected: static struct AFX_MSGMAP const CCmdTarget::messageMap"
    (?messageMap@CCmdTarget@@1UAFX_MSGMAP@@B)
    Common.lib(BThread.obj) : error LNK2001: unresolved external symbol "protected: static struct AFX_MSGMAP const CCmdTarget::messageMap" (?messageMap@CCmdTarget@@1UAFX_MSGMAP@@B)
    Common.lib(ManagerThread.obj) : error LNK2001: unresolved external symbol "protected: static struct AFX_MSGMAP const CCmdTarget::messageMap" (?messageMap@CCmdTarget@@1UAFX_MSGMAP@@B)
    Common.lib(ArgosMessage.obj) : error LNK2001: unresolved external symbol "char const * const _afxPchNil" (?_afxPchNil@@3PBDB)
    Common.lib(InmarsatCMessage.obj) : error LNK2001: unresolved external symbol "char const * const _afxPchNil" (?_afxPchNil@@3PBDB)
    Common.lib(SocketThread.obj) : error LNK2001: unresolved external symbol "char const * const _afxPchNil" (?_afxPchNil@@3PBDB)
    Common.lib(Session.obj) : error LNK2001: unresolved external symbol "char const * const _afxPchNil" (?_afxPchNil@@3PBDB)
    Common.lib(ArgosSession.obj) : error LNK2001: unresolved external symbol "char const * const _afxPchNil" (?_afxPchNil@@3PBDB)
    Common.lib(InmarsatCSession.obj) : error LNK2001: unresolved external symbol "char const * const _afxPchNil" (?_afxPchNil@@3PBDB)
    Common.lib(BThread.obj) : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CWinThread::classCWinThread" (?classCWinThread@CWinThread@@2UCRuntimeClass@@B)
    Common.lib(ManagerThread.obj) : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CWinThread::classCWinThread" (?classCWinThread@CWinThread@@2UCRuntimeClass@@B)
    Common.lib(Generic.obj) : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CObject::classCObject" (?classCObject@CObject@@2UCRuntimeClass@@B)
    Common.lib(ClientSocket.obj) : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CSocket::classCSocket" (?classCSocket@CSocket@@2UCRuntimeClass@@B)
    Common.lib(ListeningSocket.obj) : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CSocket::classCSocket" (?classCSocket@CSocket@@2UCRuntimeClass@@B)
    Release/Server1_7.exe : fatal error LNK1120: 5 unresolved externals
    Error executing link.exe.

    Server1_7.exe - 15 error(s), 0 warning(s)

    I'm weak at determining the cause of link errors (especially when it isn't my code). If anybody who is good at link error can give me some advice, I'd appreciate it greatly.

    Thank You


  2. #2
    Join Date
    Apr 1999
    Posts
    150

    Re: Link error- unresolved external symbols

    >> (especially when it isn't my code).
    Does this mean you are trying to link a project using some third party library? If so I suspect that the compile options for your project are not the same as the compile options for the library. Things such as multi-threaded in one project and not for another can cause these kinds of problems. Also, is MFC to be linked statically or dynamically? If this differs for the two projects then you got problems as well.

    Chris


  3. #3
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,716

    Re: Link error- unresolved external symbols

    Before you told the linker to ignore nafxcw.lib, where you getting unresolved symbols or multiply defined symbols. If the latter, you can have the linker ignore these errors by doing the following :


    instead of /nodefaultlib:"nafxcw.lib" , try this :

    go into "project" , "setting" , "link" ,

    for "catgory" choose "customize" and check the box "force file output"

    This will allow for multiply defined symbols



  4. #4
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,515

    Re: Link error- unresolved external symbols

    I know this is a 10 year old thread but in case anyone finds it in a search, I've just encountered this problem myself in an old project that I needed to go back and modify. AFAICT, the error about a missing symbol _afxPchNil is caused by using MFC components in a non-MFC project. In my case I tried to add a function which used CFile but any other MFC object caused the same issue. Commenting out the MFC parts (or in my case, replacing the CFile stuff with standard 'C' functions) made the problem go away.

    I haven't used MFC for many years and I can't quite remember what exactly qualifies a project (or a source module) to be acceptable as an MFC component but it's not quite as simple as #indluding stdafx.h
    "A problem well stated is a problem half solved. - Charles F. Kettering

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)