none
LNK2005, LNK 4217 & LNK 4049 - Visual Studio Linker Project Settings for MFC & ATL

    Question

  • Please help! I've been very curious with LNK2005 errors. I've got these error messages when I build with 'debug configuration' in my Visual Studio 2005 Professional IDE:

    ------ Build started: Project: TestMFCWidcomm, Configuration: Debug Win32 ------
    Linking...
    atlsd.lib(atltrace.obj) : error LNK2005: "unsigned int (__stdcall* ATL::g_pfnGetThreadACP)(void)" (?g_pfnGetThreadACP@ATL@@3P6GIXZA) already defined in atls.lib(atltrace.obj)
    atlsd.lib(Externs.obj) : error LNK2005: "char const * const g_pszUpdateEventName" (?g_pszUpdateEventName@@3PBDB) already defined in atls.lib(Externs.obj)
    atlsd.lib(Externs.obj) : error LNK2005: "char const * const g_pszAllocFileMapName" (?g_pszAllocFileMapName@@3PBDB) already defined in atls.lib(Externs.obj)
    atlsd.lib(Externs.obj) : error LNK2005: "char const * const g_pszKernelObjFmt" (?g_pszKernelObjFmt@@3PBDB) already defined in atls.lib(Externs.obj)
    atlsd.lib(Externs.obj) : error LNK2005: "class CAtlAllocator g_Allocator" (?g_Allocator@@3VCAtlAllocator@@A) already defined in atls.lib(Externs.obj)
       Creating library D:\Development\VCPP24H\TestMFCWidcomm\Debug\TestMFCWidcomm.lib and object D:\Development\VCPP24H\TestMFCWidcomm\Debug\TestMFCWidcomm.exp
    blueclasses.obj : warning LNK4217: locally defined symbol ??0CBtIf@@QAE@XZ (public: __thiscall CBtIf::CBtIf(void)) imported in function "public: __thiscall CBtIfImpl::CBtIfImpl(void)" (??0CBtIfImpl@@QAE@XZ)
    blueclasses.obj : warning LNK4217: locally defined symbol ??1CBtIf@@UAE@XZ (public: virtual __thiscall CBtIf::~CBtIf(void)) imported in function "public: virtual __thiscall CBtIfImpl::~CBtIfImpl(void)" (??1CBtIfImpl@@UAE@XZ)
    TestMFCWidcomm.obj : warning LNK4217: locally defined symbol ??1CFtpClient@@UAE@XZ (public: virtual __thiscall CFtpClient::~CFtpClient(void)) imported in function "public: virtual __thiscall CWidcommDlg::~CWidcommDlg(void)" (??1CWidcommDlg@@UAE@XZ)
    WidcommDlg.obj : warning LNK4049: locally defined symbol ??1CFtpClient@@UAE@XZ (public: virtual __thiscall CFtpClient::~CFtpClient(void)) imported
    WidcommDlg.obj : warning LNK4217: locally defined symbol ??0CFtpClient@@QAE@XZ (public: __thiscall CFtpClient::CFtpClient(void)) imported in function "public: __thiscall CWidcommDlg::CWidcommDlg(class CWnd *)" (??0CWidcommDlg@@QAE@PAVCWnd@@@Z)
    WidcommDlg.obj : warning LNK4217: locally defined symbol ?StartInquiry@CBtIf@@QAEHXZ (public: int __thiscall CBtIf:Tongue TiedtartInquiry(void)) imported in function "public: void __thiscall CWidcommDlg:SurprisenBnClickedInquire(void)" (?OnBnClickedInquire@CWidcommDlg@@QAEXXZ)
    D:\Development\VCPP24H\TestMFCWidcomm\Debug\TestMFCWidcomm.exe : fatal error LNK1169: one or more multiply defined symbols found
    Build log was saved at "file://d:\Development\VCPP24H\TestMFCWidcomm\TestMFCWidcomm\Debug\BuildLog.htm"
    TestMFCWidcomm - 6 error(s), 6 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    It's doing fine with release build, and also if I specify /FORCE:MULTIPLE in the debug version's linker command line (the latter will however, causes unhandled exception within internal of MFC libs).

    Some clues are:
    The problem occurs after I add multiple inheritance ", public CFtpClient" in
    [class CWidcommDlg : public CDialog, public ConnManager, public CFtpClient { ... ... ...} ], if I remove ", public CFtpClient" from that line, the project will build, link and run without any errors.
    However, I am sure that I have the correct library linked in, this is because I've got other project working dandy fine with the exact SAME project properties settings and similar case: this is the code that works fine with similar settings:
    [class CBlueClientDlg : public CDialog, public CBtIf, public COppClient, public CFtpClient{ ... ... ...}]

    I've been trying to google my way out, but some of those solution for others seems to add in more errors like (MSUtils.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4, therefore, I undone the tips and decide to consult the MS Profs. Thank you very much in advance!!!

    Cheers,

    KIM

    Tuesday, February 26, 2008 12:25 AM

All replies

  • I see that you are getting the overwhelming response to Widcomm related issues that I'm getting used to.

    At least part of the problem is because '_BTWLIB' is not defined. It looks like you have derived a class from Widcomm's CBtIf class and this requires _BTWLIB or you will get the warning about the 'locally defined symbol'.
    Wednesday, August 5, 2009 6:30 PM
  • Richard I don't know how to thank you for finally getting this answer after six hours of going through the samples, reading the sdk over and over again, contemplating between MFC, ATL, WIN32 or and ofcourse not to give up.


    Signature series
    Sunday, March 14, 2010 9:54 AM