给自己留个记忆
大概报错是这样
>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __cdecl std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QEAA@XZ) 已经在 libcpmtd.lib(xlock.obj) 中定义
>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __cdecl std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QEAA@H@Z) 已经在 libcpmtd.lib(xlock.obj) 中定义
>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)" (?_Debug_message@std@@YAXPEB_W0I@Z) 已经在 libcpmtd.lib(stdthrow.obj) 中定义
>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: void __cdecl std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QEAAXXZ) 已经在 BehaviorTree.obj 中定义
>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __cdecl std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QEAA@XZ) 已经在 BehaviorTree.obj 中定义
>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __cdecl std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QEAA@XZ) 已经在 BehaviorTree.obj 中定义
....
发生这种情况,首先,打开json工程,右键-->属性-->C/C++-->代码生成-->运行库 查询此选择的属性 和你的工程属性是否相同,需要保持一致才可以。
这个时候有可能还会遇到另外一个问题:
#error : Please use the /MD switch for _AFXDLL builds
我的做法是 在将”运行库”设置为MTd的同时,再将”属性页->配置属性->常规->MFC的使用”改为”在静态库中使用MFC”
即可。 (MT静态编译的选项,而MD是动态编译的选项)
同样的道理,想要动态编译时,对于:
错误 1 error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
需要将”属性页->配置属性->常规->MFC的使用”设置为”在共享DLL中使用MFC”,同时将”属性页->配置属性->C/C++->代码生成->运行库”设置为”多线程DLL(/MD)”补充:(/MD)和(/MT)是编译Release版本用的,(/MDd)和(/MTd)是编译Debug版本用的