Results 1 to 8 of 8

Thread: Link error when adding MFC header in dll project

  1. #1
    emoly is offline Registered User
    Join Date
    Mar 2005
    Posts
    12

    Unhappy 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: _DllMain@12 already defined in Netids_Connect.obj
    nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in MSVCRTD.lib(MSVCRTD.dll)
    nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in msvcprtd.lib(delop_s.obj)
    nafxcwd.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in Netids_Connect.obj; second definition ignored
    nafxcwd.lib(afxmem.obj) : warning LNK4006: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in MSVCRTD.lib(MSVCRTD.dll); second definition ignored
    nafxcwd.lib(afxmem.obj) : warning LNK4006: "void __cdecl operator delete(void *)" (??3@YAXPAX@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!
    LiuYing
    National Research Center for Intelligent Computing Systems(NCIC)
    Institute of Computing Technology
    Chinese Academy of Sciences
    http://www.ncic.ac.cn

    Our project's name is still in borning, but we call our system DBroker.

  2. #2
    ffmpeg4nmm's Avatar
    ffmpeg4nmm is offline Registered User
    Name: Smart Song
    Organization: fastreaming network multimedia Ltd.
    Project: CDMA
    Join Date
    Jun 2005
    Posts
    11
    What's your MFC run-time library?
    try to change it to "Debug Multithreaded DLL",if not!

  3. #3
    emoly is offline Registered User
    Join Date
    Mar 2005
    Posts
    12
    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: _DllMain@12 already defined in Netids_Connect.obj
    mfcs42d.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 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)
    LiuYing
    National Research Center for Intelligent Computing Systems(NCIC)
    Institute of Computing Technology
    Chinese Academy of Sciences
    http://www.ncic.ac.cn

    Our project's name is still in borning, but we call our system DBroker.

  4. #4
    matthew's Avatar
    matthew is offline ZeroC Staff
    Name: Matthew Newhook
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Feb 2003
    Location
    NL, Canada
    Posts
    1,458
    Did you look at the other MFC demos that are included with the Ice distribution and their build flags?

  5. #5
    emoly is offline Registered User
    Join Date
    Mar 2005
    Posts
    12
    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?
    LiuYing
    National Research Center for Intelligent Computing Systems(NCIC)
    Institute of Computing Technology
    Chinese Academy of Sciences
    http://www.ncic.ac.cn

    Our project's name is still in borning, but we call our system DBroker.

  6. #6
    matthew's Avatar
    matthew is offline ZeroC Staff
    Name: Matthew Newhook
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Feb 2003
    Location
    NL, Canada
    Posts
    1,458
    I'm not sure, but this doesn't appear to be anything Ice specific.

  7. #7
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,140
    A search on Google gave me this link on the Microsoft web site:

    http://support.microsoft.com/default...;en-us;q148652

    It looks very similar to your problem!

  8. #8
    emoly is offline Registered User
    Join Date
    Mar 2005
    Posts
    12

    Talking

    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!
    LiuYing
    National Research Center for Intelligent Computing Systems(NCIC)
    Institute of Computing Technology
    Chinese Academy of Sciences
    http://www.ncic.ac.cn

    Our project's name is still in borning, but we call our system DBroker.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. ICE Server support MFC project based dialog?
    By mrliuhua in forum Help Center
    Replies: 1
    Last Post: 10-26-2009, 05:42 AM
  2. Create MFC DLL error
    By jyq in forum Help Center
    Replies: 1
    Last Post: 02-23-2006, 01:13 AM
  3. in MFC dialog project Detected memory leaks!
    By dzw in forum Help Center
    Replies: 2
    Last Post: 07-29-2004, 12:15 AM
  4. MFC DLL with ICE
    By amrufon in forum Help Center
    Replies: 2
    Last Post: 08-13-2003, 02:18 AM

Posting Permissions

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