Linking googleTest in VS2010 leads to LNK2005 due to other dependent libraries

I have a large and complex project that finally gets unit tests. I created googleTest 1.6.0 locally with Visual Studio 2010, project files created using cmake as indicated by README.

This project has many dependent libraries that are statically and dynamically linked. Many of them are property. All binding attempts generate 220 such errors. Here is a sample:

msvcprtd.lib (MSVCP100D.dll): LNK2005 error: "public: void __cdecl std :: _ Container_base12 :: _ Orphan_all (void)" (? _Orphan_all @ _Container_base12 @std @@ QEAAXXZ) already defined in gtest.lib (gtest.lib (gtest.lib (gtest.lib -all.obj)

libcpmtd.lib (cerr.obj): LNK2005 error: "protected: char * __cdecl std :: basic_streambuf> :: _ Gndec (void)" (? _Gndec @? $ basic_streambuf @DU? $ char_traits @D @std @@@ std @@ IEAAPEADXZ) already defined in msvcprtd.lib (MSVCP100D.dll)

LIBCMTD.lib (setlocal.obj): LNK2005 error: _configthreadlocale already defined in MSVCRTD.lib (MSVCR100D.dll)

LINK: warning LNK4098: defaultlib 'MSVCRTD' conflicts with other libs; use / NODEFAULTLIB: LINK library: warning LNK4098: defaultlib 'LIBCMTD' conflicts with other libs; use / NODEFAULTLIB: library

fatal error LNK1169: one or more found multiplier characters were detected

I tried the / NODEFAULTLIB flag and I tried to ignore only msvcprtd.lib, MSVCRTD.lib and LIBCMTD.lib, as suggested, but then I suffer from unresolved characters ...

Both projects and googleTest are compiled using x64, / MP, / MDd and no / clr.

I played with compiler flags, wondering if there is any version mismatch. Dambbin, as I understand it, did not hint at anything that he could understand. I was hoping for er

+7
source share
1 answer

It looks like your question was answered in the Google Talk FAQ . Make sure all your libraries use the / MD (d) switch.

+10
source

All Articles