Linking googleTest in VS2010 results in LNK2005 because of other dependent libraries

前端 未结 1 905
被撕碎了的回忆
被撕碎了的回忆 2021-01-05 10:09

I have a large and complicated project that is finally getting unit tests. I\'ve built googleTest 1.6.0 locally with Visual Studio 2010, the project files built with cmake a

相关标签:
1条回答
  • 2021-01-05 10:42

    It looks like your question is answered in Google Talk's FAQ. Make sure all your libraries use the /MD(d) setting.

    You may get a number of the following linker error or warnings if you attempt to link your test project with the Google Test library when your project and the are not built using the same compiler settings.

    • LNK2005: symbol already defined in object
    • LNK4217: locally defined symbol 'symbol' imported in function 'function'
    • LNK4049: locally defined symbol 'symbol' imported The Google Test project (gtest.vcproj) has the Runtime Library option set to /MT (use multi-threaded static libraries, /MTd for debug). If your project uses something else, for example /MD (use multi-threaded DLLs, /MDd for debug), you need to change the setting in the Google Test project to match your project's.

    To update this setting open the project properties in the Visual Studio IDE then select the branch Configuration Properties | C/C++ | Code Generation and change the option "Runtime Library". You may also try using gtest-md.vcproj instead of gtest.vcproj.

    0 讨论(0)
提交回复
热议问题