Home Help Center

Link error when adding MFC header in dll project

Hi,
We build a dll lib with ICE 2.1.0 and VC6.0. Now a MFC messagebox needs to be added in this dll lib. But once we inlude <afxwin.h>, the dll project can't be compiled.
The error is:

Configuration: Netids_Connect - Win32 Debug
Compiling...
StdAfx.cpp
Compiling...
Netids_Connect.cpp
QueryServer.cpp
QueryServerFactory.cpp
Generating Code...
Linking...
nafxcwd.lib(dllmodul.obj) : error LNK2005: [email protected] already defined in Netids_Connect.obj
nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" ([email protected]@Z) already defined in MSVCRTD.lib(MSVCRTD.dll)
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" ([email protected]@Z) already defined in msvcprtd.lib(delop_s.obj)
nafxcwd.lib(dllmodul.obj) : warning LNK4006: [email protected] already defined in Netids_Connect.obj; second definition ignored
nafxcwd.lib(afxmem.obj) : warning LNK4006: "void * __cdecl operator new(unsigned int)" ([email protected]@Z) already defined in MSVCRTD.lib(MSVCRTD.dll); second definition ignored
nafxcwd.lib(afxmem.obj) : warning LNK4006: "void __cdecl operator delete(void *)" ([email protected]@Z) already defined in msvcprtd.lib(delop_s.obj); second definition ignored
Creating library Debug/Netids_Connect.lib and object Debug/Netids_Connect.exp
nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
nafxcwd.lib(timecore.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcwd.lib(filelist.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcwd.lib(apphelp.obj) : error LNK2001: unresolved external symbol __mbctype
Debug/Netids_Connect.dll : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
Creating browse info file...

Netids_Connect.dll - 9 error(s), 3 warning(s)
How can I resolve this problem? Is it anything uncomportable between ice stlport and VC6.0?

Thank you!

Comments

  • ffmpeg4nmmffmpeg4nmm Member Smart SongOrganization: fastreaming network multimedia Ltd.Project: CDMA
    What's your MFC run-time library?
    try to change it to "Debug Multithreaded DLL",if not!
  • emolyemoly Member
    I have used /MDd option
    The MFC run-time library is "C:\Program Files\Microsoft Visual Studio\VC98\MFC\LIB".
    When I change above directory to the top of VC library files, the error is less than before.
    Linking...
    mfcs42d.lib(dllmodul.obj) : error LNK2005: [email protected] already defined in Netids_Connect.obj
    mfcs42d.lib(dllmodul.obj) : warning LNK4006: [email protected] already defined in Netids_Connect.obj; second definition ignored
    Creating library Debug/Netids_Connect.lib and object Debug/Netids_Connect.exp
    Debug/Netids_Connect.dll : fatal error LNK1169: one or more multiply defined symbols found
    Error executing link.exe.

    Netids_Connect.dll - 2 error(s), 1 warning(s)
  • matthewmatthew NL, CanadaMember Matthew NewhookOrganization: ZeroC, Inc.Project: Internet Communications Engine ✭✭✭
    Did you look at the other MFC demos that are included with the Ice distribution and their build flags?
  • emolyemoly Member
    I have seen those demos and I use the same flags as them.
    There is something different between dll and obj. If I use mfc to create obj, it's OK. But if I use mfc to create dll, the link error will happen.

    What's wrong with the dll or what especial configuration is needed by dll project?
  • matthewmatthew NL, CanadaMember Matthew NewhookOrganization: ZeroC, Inc.Project: Internet Communications Engine ✭✭✭
    I'm not sure, but this doesn't appear to be anything Ice specific.
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    A search on Google gave me this link on the Microsoft web site:

    http://support.microsoft.com/default.aspx?scid=kb;en-us;q148652

    It looks very similar to your problem!
  • emolyemoly Member
    Hi,
    I find something possible to cause the link problem. It is maybe wrong use of _USRDLL and _AFXDLL together.

    _USRDLL:compiling regular DLLs that statically link to MFC
    _AFXDLL:compiling regular DLLs that dynamically link to MFC

    The latter is what we need, so remove _USRDLL in the preprocessor definitions.
    Now ,compling is OK. I hope the project will work too.

    I'm so sorry to trouble you.

    Thank you all for your help very much!
Sign In or Register to comment.