🔒 Locked
MFC problem
Advertisement
Original Post
I wrote a program(win32 EXE) that will call a static dll and the dll used MFC(CString). should i set the project to Not using MFC or use MFC in static library? However, i tried those of options, compile error occur. I tried use MFC in shared dll, the program can run. However, the program need publish those of the dll files. e.g. MFC42D.DLL....
How can i fix this problem? which option should i use? Thx a lot of.
Right! I set the project that not using MFC. Here is the error statement. Pls help
Compiling...
JTControl.cpp
Linking...
nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCD.lib(new.obj)
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in libcpd.lib(delop.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _memmove already defined in LIBCD.lib(memmove.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _free already defined in LIBCD.lib(dbgheap.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _calloc already defined in LIBCD.lib(dbgheap.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _atoi already defined in LIBCD.lib(atox.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: __atoi64 already defined in LIBCD.lib(atox.obj)
LINK : warning LNK4098: defaultlib "mfc42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "mfcs42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
Debug/JoinTable.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
JoinTable.exe - 8 error(s), 3 warning(s)
Compiling...
JTControl.cpp
Linking...
nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCD.lib(new.obj)
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in libcpd.lib(delop.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _memmove already defined in LIBCD.lib(memmove.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _free already defined in LIBCD.lib(dbgheap.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _calloc already defined in LIBCD.lib(dbgheap.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _atoi already defined in LIBCD.lib(atox.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: __atoi64 already defined in LIBCD.lib(atox.obj)
LINK : warning LNK4098: defaultlib "mfc42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "mfcs42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
Debug/JoinTable.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
JoinTable.exe - 8 error(s), 3 warning(s)
your crt and mfc libs are mismatched. the following are 4 valid configurations.
debug build, static linking:
- set crt to "multithreaded debug"
- set mfc to "use mfc in static library"
release build, static linking:
- set crt to "multithreaded"
- set mfc to "use mfc in static library"
debug build, dynamic linking:
- set crt to "multithreaded debug dll"
- set mfc to "use mfc in shared dll"
release build, dynamic linking:
- set crt to "multithreaded dll"
- set mfc to "use mfc in shared dll"
note that mfc headers will pull in appropriate debug/release mfc libs based on whether _DEBUG is defined or not.
change crt library settings in project settings->c++->code generation->c runtime. mfc library settings are in project settings->general->use of mfc.
debug build, static linking:
- set crt to "multithreaded debug"
- set mfc to "use mfc in static library"
release build, static linking:
- set crt to "multithreaded"
- set mfc to "use mfc in static library"
debug build, dynamic linking:
- set crt to "multithreaded debug dll"
- set mfc to "use mfc in shared dll"
release build, dynamic linking:
- set crt to "multithreaded dll"
- set mfc to "use mfc in shared dll"
note that mfc headers will pull in appropriate debug/release mfc libs based on whether _DEBUG is defined or not.
change crt library settings in project settings->c++->code generation->c runtime. mfc library settings are in project settings->general->use of mfc.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement