Archived
This forum has been archived. Please start a new discussion on GitHub.
Link error when adding MFC header in dll project
in Help Center
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!
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!
0
Comments
-
What's your MFC run-time library?
try to change it to "Debug Multithreaded DLL",if not!0 -
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)0 -
Did you look at the other MFC demos that are included with the Ice distribution and their build flags?0
-
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?0 -
I'm not sure, but this doesn't appear to be anything Ice specific.0
-
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!0 -
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!0