#include fstream error

Started by
2 comments, last by mvtapia 18 years, 11 months ago
hello everyone I have a rather simple link error on the the ifstream function the include by its self is fine no error but when I include this in the code: ifstream savedfiles[5]; I get this link error: nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj) nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj) nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in LIBCMTD.lib(delete2.obj) any suggestion, thanks.
Marco Tapia
Advertisement
A library that visual studio links to your project, by default, is conflicting with your library (or app). Under project properties, select the tab [or list box item] that will provide the dialog that will allow you to adjust the linker settings for your project. In the "ignore libraries" field, type in 'LIBCMTD' (without the quotes). This will cause the linker to ignore this library when linking your program. If you intend on building in release mode, you will also have to tell the linker to ignore 'LIBCMT', the non-debug version of the same library, as well.

[EDIT] -didn't see the 'MT' part -it may very well have to do with threading conflicts, as mentat suggested. Ignoring the library will work, but you may want to use the multi-threaded versions of the other libraries you are using, or build them to allow multi-threading.
you are mixing libraries linked with different options (multithreaded vs single threaded). Check your linker options and try using all libraries compiled with the same linker option. Or, try specifically ignoring libcmtd.lib from the input libraries.
-----------my quote is under construction
I'm sorry guys but I tryed that and I get like 300 linker errors... I'm kind of new to VC++ and I don't understand the concept of multi-threaded versions of the library. Is there another library I should include to be able to use fstream.
Marco Tapia

This topic is closed to new replies.

Advertisement