Monday, 6 March 2017

Failed to use C++ Rest SDK and Microsoft unit test at the same time

I have a MFC project which uses C++ Rest SDK (Casablanca) under Visual Studio 2012 to implement an http client connection and it can be compiled well.
Then I add a Microsoft unit test project, but I can’t build the unit test project successfully.
In my main project, the environment is set as “Use MFC in a Static Library”, “No Common Language Runtime Support” and “Multi-threaded Debug (/MTd).” And my test project’s environment is same as main project. The error message shows:





“error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in libcpmtd.lib(newaop.obj).”




In addition, I also try to change the test project’s environment to “Common Language Runtime Support (/clr)” and “Multi-threaded Debug DLL (/MDd).” The original error disappears but new error comes:




“error C1189: #error : is not supported when compiling with /clr or /clr:pure. c:\program files (x86)\microsoft visual studio 11.0\vc\include\atomic line 9”




I do not know how to overcome these problems. Can anyone please give me some suggestions or resolutions? Thanks.

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...