Skip to main content
gamedev.net
🔒 Locked

MFC problem

Started by wah_on_2 Dec 9, 2002 at 4:39 AM 9 replies 1.1k views
Original Post
wah_on_2
wah_on_2
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.
niyaw
niyaw
post exact error message if you''re asking for help with one.
wah_on_2
wah_on_2
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)
wah_on_2
wah_on_2
No one know how to fix it?? >"<
kuphryn
kuphryn
I have not been able to compile an MFC program that uses independent DLL and "buildin" MFC DLL. In other words, you have to include your private DLLs and the required MFC DLLs externally.

Kuphryn
niyaw
niyaw
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.
niyaw
niyaw
quote:
Original post by wah_on_2
I wrote a program(win32 EXE) that will call a static dll and the dll used MFC(CString).

there is no such thing as a "static dll". are you referring to a dll that does not use mfc or to a static libary (.lib)?
wah_on_2
wah_on_2
I followed the steps but the problems are still occur. Pls help.
niyaw
niyaw
make sure *all* your projects have the same crt/mfc usage settings.

if you still get errors after that, go to linker options and ignore libraries that don''t fit in the combination you''re using. from your errors, it seems that libcd.lib is out of place, so ignore that.
wah_on_2
wah_on_2
The problem fixed after i ignore some libraries. Thx a lot of. ^_^

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.