Jump to content
  • Advertisement
Sign in to follow this  
mvtapia

#include fstream error

This topic is 4831 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!