3

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 : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library

However, the following command doesn't seem to work.

cl main.cpp complex.cpp testset.cpp /I"C:\CppUnit\include" /link /libpath:"C:\CppUnit\lib" cppunit.lib /NODEFAULTLIB:library

What's wrong with them?

This is the command that I used for compilation/link.

cl main.cpp complex.cpp testset.cpp /I"C:\CppUnit\include" /link /libpath:"C:\CppUnit\lib" cppunit.lib

This is the error message from VS2010.

cppunit.lib(TestResult.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': 

...

node@@@Z) already defined in LIBCMT.lib(typinfo.obj)
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:lib
rary
main.exe : fatal error LNK1169: one or more multiply defined symbols found

ADDED

The CppUnit provides older version of project file (dsw), so I needed to convert the file to 2010 solution project manually.

For the error, missing /MD for compilation was the source of the problem. For other compilation warning, I needed to add /EHsc parameter.

cl /EHsc /MD /c /I"./CppUnit/include" main.cpp testset.cpp complex.cpp
link /libpath:"CppUnit/lib" main.obj testset.obj complex.obj cppunit.lib /out:cpptest_static.exe
link /libpath:"CppUnit/lib" main.obj testset.obj complex.obj cppunit_dll.lib /out:cpptest_dynamic.exe

3 Answers 3

2

seems like you compiled CppUnit in debug mode, weheras you're now compiling your current files in release mode. Those should not be mixed, and that's what the compiler is telling you.

The quickest way to resolve this would probably be to use a VS project, and check it's settings against the project used to compile CppUnit.

on your edit: you're also mixing runtime libraries (eg check that both are compiled using the /MD switch aka Multi-Threaded DLL)

1

I upgraded my CPPUNIT projects to visual studio 2010 and had to manually fix it. The problem in the build was in the final actions where the output files are copied.

For the cppunit_dll project, one of the custom commands is:

copy "$(TargetPath)" ..\..\lib\$(TargetName).dll
copy "$(TargetDir)$(TargetName).lib" ..\..\lib\$(TargetName).lib

$(TargetName) is "cppunit_dll".

This conflicts with what we're actually building: if you look at the Linker options, you see that the output file name is "cppunitd_dll.dll".

The solution I used is to go to ConfigurationPropertys\General, and change "Target Name" from $(ProjectName) to"cppunitd_dll".

I had to to a similar solution for the cppunit project.

0

read INSTALL-VS.Net2008.txt in the cppunit folder after checking out the source code from SVN.

basically: there is a visual studio solution under the examples folder.

that being said... i still can't get it to build without errors on vs2010 after converting it. i get 'cmd.exe' failed and failures to copy dlls.

1
  • I've answered this bit for you. Commented Jul 6, 2011 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.