I have found other examples of people having this problem but have had no luck with their solutions. I am trying to use std::cout in a static library that also uses boost threads and bind. When I don't use and std::cout
it compiles and links fine with the main program but when I do and I compile the library I have no problems but when I compile and link the main program that uses the static library I get a ton of things like:
2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRTD.lib(cinitexe.obj) 2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRTD.lib(cinitexe.obj) 2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRTD.lib(cinitexe.obj) 2>LIBCMT.lib(mlock.obj) : error LNK2005: __unlock already defined in MSVCRTD.lib(MSVCR100D.dll) 2>LIBCMT.lib(mlock.obj) : error LNK2005: __lock already defined in MSVCRTD.lib(MSVCR100D.dll) 2>LIBCMT.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in MSVCRTD.lib(MSVCR100D.dll) 2>LIBCMT.lib(crt0.obj) : error LNK2005: _mainCRTStartup already defined in MSVCRTD.lib(crtexe.obj)
etc...
I have tried going in to my linker settings and stopping it from using the conflicting library listed in the error output, but I can't get it right. If I tell it to stop using one library it may fix the problems but give me a few missing external symbols, then I switch the library it was having problems with but I still get a few "already defined". Any clues to what I can do to fix this? Should I just make another class called "log" or something and just access it from the main .exe (which would use the strings library, which may cause problems again but I haven't tried it yet)? Thank you for any help.
Try checking -> Project + Properties, C/C++, Code Generation, Runtime library. Your .lib and your main project must use the same setting here.