{"id":5467,"date":"2014-03-30T22:24:22","date_gmt":"2014-03-30T22:24:22","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/building-using-cppunit-library-on-vs2010-collection-of-common-programming-errors\/"},"modified":"2014-03-30T22:24:22","modified_gmt":"2014-03-30T22:24:22","slug":"building-using-cppunit-library-on-vs2010-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/building-using-cppunit-library-on-vs2010-collection-of-common-programming-errors\/","title":{"rendered":"Building\/Using CppUnit Library on VS2010-Collection of common programming errors"},"content":{"rendered":"<p>I downloaded and compiled CppUnit to compile with Visual Studio 2010.<\/p>\n<p>After the conversion, I could load the CppUnitLibraries, and it gives me cppunit.lib and cppunit_dll.lib\/dll. After copying the headers and libs to a directory, I run this command to get a lot of errors.<\/p>\n<p>I found the conflict of libraries as follows<\/p>\n<pre><code>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use \/NODEFAULTLIB:library\n<\/code><\/pre>\n<p>However, the following command doesn&#8217;t seem to work.<\/p>\n<pre><code>cl main.cpp complex.cpp testset.cpp \/I\"C:\\CppUnit\\include\" \/link \/libpath:\"C:\\CppUnit\\lib\" cppunit.lib \/NODEFAULTLIB:library\n<\/code><\/pre>\n<p>What&#8217;s wrong with them?<\/p>\n<p>This is the command that I used for compilation\/link.<\/p>\n<pre><code>cl main.cpp complex.cpp testset.cpp \/I\"C:\\CppUnit\\include\" \/link \/libpath:\"C:\\CppUnit\\lib\" cppunit.lib\n<\/code><\/pre>\n<p>This is the error message from VS2010.<\/p>\n<pre>\ncppunit.lib(TestResult.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': \n\n...\n\nnode@@@Z) already defined in LIBCMT.lib(typinfo.obj)\nLINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use \/NODEFAULTLIB:lib\nrary\nmain.exe : fatal error LNK1169: one or more multiply defined symbols found\n<\/pre>\n<h2>ADDED<\/h2>\n<p>The CppUnit provides older version of project file (dsw), so I needed to convert the file to 2010 solution project manually.<\/p>\n<p>For the error, missing \/MD for compilation was the source of the problem. For other compilation warning, I needed to add \/EHsc parameter.<\/p>\n<pre><code>cl \/EHsc \/MD \/c \/I\".\/CppUnit\/include\" main.cpp testset.cpp complex.cpp\nlink \/libpath:\"CppUnit\/lib\" main.obj testset.obj complex.obj cppunit.lib \/out:cpptest_static.exe\nlink \/libpath:\"CppUnit\/lib\" main.obj testset.obj complex.obj cppunit_dll.lib \/out:cpptest_dynamic.exe\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I downloaded and compiled CppUnit to compile with Visual Studio 2010. After the conversion, I could load the CppUnitLibraries, and it gives me cppunit.lib and cppunit_dll.lib\/dll. After copying the headers and libs to a directory, I run this command to get a lot of errors. I found the conflict of libraries as follows LINK : [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5467","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5467"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5467\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}