在使用cppunit,搭建测试环境时遇到的问题以及解决办法(仅供参考)

寄语:虽然很杂乱,但确实能解决问题


2013-1-22 11:20:11.

------ Build started: Project: cppunit, Configuration: Debug Win32 ------

Build started 2013-1-22 11:20:11.

InitializeBuildStatus:

  Touching ".\Debug\cppunit.unsuccessfulbuild".

ClCompile:

  All outputs are up-to-date.

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(1151,5): warning MSB8012: TargetPath(D:\new try\cppunit-1.12.1\src\cppunit\.\Debug\cppunit.lib) does not match the Library's OutputFile property value (D:\new try\cppunit-1.12.1\src\cppunit\Debug\cppunitd.lib). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile).

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(1153,5): warning MSB8012: TargetName(cppunit) does not match the Library's OutputFile property value (cppunitd). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile).

原因:工程cppunit的属性设置中,librarian——general——output file设置为Debug\cppunitd.lib;

以及工程cppunit的属性设置中,configuration properties——general——target name 设置的是默认以项目名命名生成的lib库文件

以上两个设置的部分不一致。

解决:将工程cppunit的属性设置中,configuration properties——general——target name 设置为cppunitd。

Lib:

  All outputs are up-to-date.

  cppunit.vcxproj -> D:\new try\cppunit-1.12.1\src\cppunit\.\Debug\cppunit.lib

PostBuildEvent:

  Description: Copying target to lib/

  系统找不到指定的文件。

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: The command "copy "D:\new try\cppunit-1.12.1\src\cppunit\.\Debug\cppunit.lib" ..\..\lib\cppunit.lib

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :VCEnd" exited with code 1.

原因:工程cppunit属性设置中,configuration properties——build events——post-build events——command line设置为copy "$(TargetPath)" ..\..\lib\$(TargetName).lib

解决:将以上设置更改如下

copy "$(TargetDir)$(TargetName).lib" ..\..\lib\$(TargetName).lib即将lib文件拷贝到上层目录lib中。

Build FAILED.

 

Time Elapsed 00:00:01.56

------ Build started: Project: TestRunner, Configuration: Debug Win32 ------

Build started 2013-1-22 11:20:13.

InitializeBuildStatus:

  Touching ".\Debug\TestRunner.unsuccessfulbuild".

ClCompile:

  All outputs are up-to-date.

  MsDevCallerListCtrl.cpp

MsDevCallerListCtrl.cpp(67): error C3505: cannot load type library '{80CC9F66-E7D8-4DDD-85B6-D9E6CD0E93E2}'

MsDevCallerListCtrl.cpp(67): fatal error C1104: fatal error importing libid: '80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2'

出错的文件是:src\msvc6\testrunner\MsDevCallerListCtrl.cpp。这是由于使用VC 8.0编译的缘故,需要修改一下它的源码,打开该文件,找到出错行(#67),将其替换为:

  #if _MSC_VER >= 1400    // VC++ 8 or more
  //The following #import imports EnvDTE based on its LIBID.
  #import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("8.0") lcid("0") raw_interfaces_only named_guids
  //The following #import imports EnvDTE80 based on its LIBID.
  #import "libid:1A31287A-4D7D-413e-8E32-3B374931BD89" version("8.0") lcid("0") raw_interfaces_only named_guids
  #else // vc7
  #import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("7.0") lcid("0") raw_interfaces_only named_guids
  #endif

 

Build FAILED.

 

重新编译,工程testrunner,又会出现如下错误!

Time Elapsed 00:01:01

------ Rebuild All started: Project: TestRunner, Configuration: Debug Win32 ------

Build started 2013-1-22 14:51:54.

_PrepareForClean:

  Deleting file ".\Debug\TestRunner.lastbuildstate".

InitializeBuildStatus:

  Touching ".\Debug\TestRunner.unsuccessfulbuild".

ClCompile:

  StdAfx.cpp

  _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)

  MostRecentTests.cpp

  TestRunnerModel.cpp

  MfcTestRunner.cpp

  ActiveTest.cpp

  TreeHierarchyDlg.cpp

  TestRunnerDlg.cpp

  TestRunnerApp.cpp

  ResourceLoaders.cpp

  ProgressBar.cpp

  MsDevCallerListCtrl.cpp

  ListCtrlSetter.cpp

  ListCtrlFormatter.cpp

  cdxCSizeIconCtrl.cpp

  cdxCDynamicWndEx.cpp

  cdxCDynamicWnd.cpp

  cdxCDynamicDialog.cpp

  Generating Code...

  TestRunnerDSPluginVC6_i.c

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(D:\new try\cppunit-1.12.1\src\msvc6\testrunner\.\Debug\TestRunner.dll) does not match the Linker's OutputFile property value (D:\new try\cppunit-1.12.1\src\msvc6\testrunner\Debug\testrunnerd.dll). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(992,5): warning MSB8012: TargetName(TestRunner) does not match the Linker's OutputFile property value (testrunnerd). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).

.\TestRunner.def(4): warning LNK4017: DESCRIPTION statement not supported for the target platform; ignored

     Creating library .\Debug\testrunnerd.lib and object .\Debug\testrunnerd.exp

  TestRunner.vcxproj -> D:\new try\cppunit-1.12.1\src\msvc6\testrunner\.\Debug\TestRunner.dll

PostBuildEvent:

  Description: Copying target to lib/

  系统找不到指定的文件。

  系统找不到指定的文件。

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: The command "copy "D:\new try\cppunit-1.12.1\src\msvc6\testrunner\.\Debug\TestRunner.dll" ..\..\..\lib\TestRunner.dll

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: copy "D:\new try\cppunit-1.12.1\src\msvc6\testrunner\Debug\TestRunner.lib" ..\..\..\lib\TestRunner.lib

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :VCEnd" exited with code 1.

原因:工程TestRunner属性设置中,configuration properties——general——target name 设置的是默认以项目名命名生成的dll库文件。但是在linker——general——output file设置的是Debug\testrunnerd.dll。以上两者的设置不一致。

解决:工程TestRunner属性设置中,configuration properties——general——target name 设置为testrunnerd

 

 

Time Elapsed 00:00:01.57

------ Build started: Project: cppunit_dll, Configuration: Debug Win32 ------

Build started 2013-1-22 11:20:15.

InitializeBuildStatus:

  Touching ".\DebugDll\cppunit_dll.unsuccessfulbuild".

ClCompile:

  XmlOutputterHook.cpp

  XmlOutputter.cpp

D:\new try\cppunit-1.12.1\include\cppunit/SourceLine.h(56): warning C4251: 'CppUnit::SourceLine::m_fileName' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::SourceLine'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

D:\new try\cppunit-1.12.1\include\cppunit/Exception.h(82): warning C4251: 'CppUnit::Exception::m_whatMessage' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::Exception'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  XmlElement.cpp

  XmlDocument.cpp

  Win32DynamicLibraryManager.cpp

  UnixDynamicLibraryManager.cpp

  TypeInfoHelper.cpp

  TextTestRunner.cpp

  TextTestResult.cpp

D:\new try\cppunit-1.12.1\include\cppunit/SourceLine.h(56): warning C4251: 'CppUnit::SourceLine::m_fileName' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::SourceLine'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

D:\new try\cppunit-1.12.1\include\cppunit/Exception.h(82): warning C4251: 'CppUnit::Exception::m_whatMessage' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::Exception'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  TextTestProgressListener.cpp

  TextOutputter.cpp

D:\new try\cppunit-1.12.1\include\cppunit/SourceLine.h(56): warning C4251: 'CppUnit::SourceLine::m_fileName' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::SourceLine'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

D:\new try\cppunit-1.12.1\include\cppunit/Exception.h(82): warning C4251: 'CppUnit::Exception::m_whatMessage' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::Exception'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  TestSuiteBuilderContext.cpp

D:\new try\cppunit-1.12.1\include\cppunit/extensions/TestNamer.h(82): warning C4251: 'CppUnit::TestNamer::m_fixtureName' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::TestNamer'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  TestSuite.cpp

  TestSuccessListener.cpp

  TestSetUp.cpp

  TestRunner.cpp

  TestResultCollector.cpp

  TestResult.cpp

D:\new try\cppunit-1.12.1\include\cppunit/SourceLine.h(56): warning C4251: 'CppUnit::SourceLine::m_fileName' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::SourceLine'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

d:\new try\cppunit-1.12.1\src\cppunit\ProtectorContext.h(31): warning C4251: 'CppUnit::ProtectorContext::m_shortDescription' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::ProtectorContext'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  TestPlugInDefaultImpl.cpp

D:\new try\cppunit-1.12.1\include\cppunit/plugin/PlugInParameters.h(27): warning C4251: 'CppUnit::PlugInParameters::m_commandLine' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::PlugInParameters'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

D:\new try\cppunit-1.12.1\include\cppunit/plugin/TestPlugInDefaultImpl.h(27): warning C4275: non dll-interface struct 'CppUnitTestPlugIn' used as base for dll-interface class 'CppUnit::TestPlugInDefaultImpl'

          D:\new try\cppunit-1.12.1\include\cppunit/plugin/TestPlugIn.h(44) : see declaration of 'CppUnitTestPlugIn'

          D:\new try\cppunit-1.12.1\include\cppunit/plugin/TestPlugInDefaultImpl.h(26) : see declaration of 'CppUnit::TestPlugInDefaultImpl'

  TestPath.cpp

  Generating Code...

  Compiling...

  TestNamer.cpp

D:\new try\cppunit-1.12.1\include\cppunit/extensions/TestNamer.h(82): warning C4251: 'CppUnit::TestNamer::m_fixtureName' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::TestNamer'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  TestLeaf.cpp

  TestFailure.cpp

D:\new try\cppunit-1.12.1\include\cppunit/SourceLine.h(56): warning C4251: 'CppUnit::SourceLine::m_fileName' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::SourceLine'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

D:\new try\cppunit-1.12.1\include\cppunit/Exception.h(82): warning C4251: 'CppUnit::Exception::m_whatMessage' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::Exception'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  TestFactoryRegistry.cpp

  TestDecorator.cpp

  TestComposite.cpp

D:\new try\cppunit-1.12.1\include\cppunit/TestComposite.h(39): warning C4251: 'CppUnit::TestComposite::m_name' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::TestComposite'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  TestCaseDecorator.cpp

D:\new try\cppunit-1.12.1\include\cppunit/SourceLine.h(56): warning C4251: 'CppUnit::SourceLine::m_fileName' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::SourceLine'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

D:\new try\cppunit-1.12.1\include\cppunit/Exception.h(82): warning C4251: 'CppUnit::Exception::m_whatMessage' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::Exception'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

D:\new try\cppunit-1.12.1\include\cppunit/TestCase.h(50): warning C4251: 'CppUnit::TestCase::m_name' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::TestCase'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  TestCase.cpp

D:\new try\cppunit-1.12.1\include\cppunit/SourceLine.h(56): warning C4251: 'CppUnit::SourceLine::m_fileName' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::SourceLine'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

D:\new try\cppunit-1.12.1\include\cppunit/Exception.h(82): warning C4251: 'CppUnit::Exception::m_whatMessage' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::Exception'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

D:\new try\cppunit-1.12.1\include\cppunit/TestCase.h(50): warning C4251: 'CppUnit::TestCase::m_name' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::TestCase'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  TestAssert.cpp

D:\new try\cppunit-1.12.1\include\cppunit/SourceLine.h(56): warning C4251: 'CppUnit::SourceLine::m_fileName' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::SourceLine'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

D:\new try\cppunit-1.12.1\include\cppunit/Exception.h(82): warning C4251: 'CppUnit::Exception::m_whatMessage' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::Exception'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  Test.cpp

  SynchronizedObject.cpp

  StringTools.cpp

  SourceLine.cpp

D:\new try\cppunit-1.12.1\include\cppunit/SourceLine.h(56): warning C4251: 'CppUnit::SourceLine::m_fileName' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::SourceLine'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  RepeatedTest.cpp

  ProtectorChain.cpp

D:\new try\cppunit-1.12.1\include\cppunit/SourceLine.h(56): warning C4251: 'CppUnit::SourceLine::m_fileName' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::SourceLine'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  Protector.cpp

D:\new try\cppunit-1.12.1\include\cppunit/SourceLine.h(56): warning C4251: 'CppUnit::SourceLine::m_fileName' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::SourceLine'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

D:\new try\cppunit-1.12.1\include\cppunit/Exception.h(82): warning C4251: 'CppUnit::Exception::m_whatMessage' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::Exception'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

d:\new try\cppunit-1.12.1\src\cppunit\ProtectorContext.h(31): warning C4251: 'CppUnit::ProtectorContext::m_shortDescription' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::ProtectorContext'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  PlugInParameters.cpp

D:\new try\cppunit-1.12.1\include\cppunit/plugin/PlugInParameters.h(27): warning C4251: 'CppUnit::PlugInParameters::m_commandLine' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::PlugInParameters'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  PlugInManager.cpp

D:\new try\cppunit-1.12.1\include\cppunit/plugin/TestPlugInDefaultImpl.h(27): warning C4275: non dll-interface struct 'CppUnitTestPlugIn' used as base for dll-interface class 'CppUnit::TestPlugInDefaultImpl'

          D:\new try\cppunit-1.12.1\include\cppunit/plugin/TestPlugIn.h(44) : see declaration of 'CppUnitTestPlugIn'

          D:\new try\cppunit-1.12.1\include\cppunit/plugin/TestPlugInDefaultImpl.h(26) : see declaration of 'CppUnit::TestPlugInDefaultImpl'

  Message.cpp

  Exception.cpp

D:\new try\cppunit-1.12.1\include\cppunit/SourceLine.h(56): warning C4251: 'CppUnit::SourceLine::m_fileName' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::SourceLine'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

D:\new try\cppunit-1.12.1\include\cppunit/Exception.h(82): warning C4251: 'CppUnit::Exception::m_whatMessage' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::Exception'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  Generating Code...

  Compiling...

  DynamicLibraryManagerException.cpp

  DynamicLibraryManager.cpp

  DllMain.cpp

  DefaultProtector.cpp

D:\new try\cppunit-1.12.1\include\cppunit/SourceLine.h(56): warning C4251: 'CppUnit::SourceLine::m_fileName' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::SourceLine'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

D:\new try\cppunit-1.12.1\include\cppunit/Exception.h(82): warning C4251: 'CppUnit::Exception::m_whatMessage' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::Exception'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  CompilerOutputter.cpp

D:\new try\cppunit-1.12.1\include\cppunit/SourceLine.h(56): warning C4251: 'CppUnit::SourceLine::m_fileName' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::SourceLine'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

D:\new try\cppunit-1.12.1\include\cppunit/Exception.h(82): warning C4251: 'CppUnit::Exception::m_whatMessage' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::Exception'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

D:\new try\cppunit-1.12.1\include\cppunit/CompilerOutputter.h(138): warning C4251: 'CppUnit::CompilerOutputter::m_locationFormat' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::CompilerOutputter'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  BriefTestProgressListener.cpp

  BeosDynamicLibraryManager.cpp

  Asserter.cpp

D:\new try\cppunit-1.12.1\include\cppunit/SourceLine.h(56): warning C4251: 'CppUnit::SourceLine::m_fileName' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::SourceLine'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

D:\new try\cppunit-1.12.1\include\cppunit/Exception.h(82): warning C4251: 'CppUnit::Exception::m_whatMessage' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::Exception'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  AdditionalMessage.cpp

  Generating Code...

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(D:\new try\cppunit-1.12.1\src\cppunit\.\DebugDll\cppunit_dll.dll) does not match the Linker's OutputFile property value (D:\new try\cppunit-1.12.1\src\cppunit\DebugDll\cppunitd_dll.dll). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(992,5): warning MSB8012: TargetName(cppunit_dll) does not match the Linker's OutputFile property value (cppunitd_dll). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).

Link:

     Creating library .\DebugDll\cppunitd_dll.lib and object .\DebugDll\cppunitd_dll.exp

LinkEmbedManifest:

     Creating library .\DebugDll\cppunitd_dll.lib and object .\DebugDll\cppunitd_dll.exp

  cppunit_dll.vcxproj -> D:\new try\cppunit-1.12.1\src\cppunit\.\DebugDll\cppunit_dll.dll

PostBuildEvent:

  Description: Copying target to lib/

  系统找不到指定的文件。

  系统找不到指定的文件。

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: The command "copy "D:\new try\cppunit-1.12.1\src\cppunit\.\DebugDll\cppunit_dll.dll" ..\..\lib\cppunit_dll.dll

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: copy "D:\new try\cppunit-1.12.1\src\cppunit\DebugDll\cppunit_dll.lib" ..\..\lib\cppunit_dll.lib

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :VCEnd" exited with code 1.

原因:在linker\general\output file中, 生成文件的名字为不带“d”的名字,在post-build中,会copy错误。修改办法:

(1)General\TargetName中,$(ProjectName)-->$(ProjectName)d,而cppunit_dll工程比较特殊,它需要在cppunitd_dll中间加"d",没办法使用$(ProjectName),可直接写为cppunitd_dll

(2)Linker\General\Output Files中,DebugDll\cppunit_dll.dll-->DebugDll\$(TargetName)$(TargetExt)

(3)Linker\Advanced\Import Libraries中,.\DebugDll\cppunit_dll.lib-->.\DebugDll\$(TargetName).lib

(4)PostBuild Event\Command Line中:改为:

copy "$(TargetPath)" ..\..\lib\$(TargetName)$(TargetExt)

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

即将dll和lib文件拷贝到上层目录lib中。

 

Build FAILED.

 

Time Elapsed 00:00:55.70

------ Build started: Project: DllPlugInTester, Configuration: Debug Win32 ------

Build started 2013-1-22 11:21:11.

InitializeBuildStatus:

  Creating ".\DebugDll\DllPlugInTester.unsuccessfulbuild" because "AlwaysCreate" was specified.

ClCompile:

  DllPlugInTester.cpp

D:\new try\cppunit-1.12.1\include\cppunit/CompilerOutputter.h(138): warning C4251: 'CppUnit::CompilerOutputter::m_locationFormat' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::CompilerOutputter'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

D:\new try\cppunit-1.12.1\include\cppunit/plugin/TestPlugInDefaultImpl.h(27): warning C4275: non dll-interface struct 'CppUnitTestPlugIn' used as base for dll-interface class 'CppUnit::TestPlugInDefaultImpl'

          D:\new try\cppunit-1.12.1\include\cppunit/plugin/TestPlugIn.h(44) : see declaration of 'CppUnitTestPlugIn'

          D:\new try\cppunit-1.12.1\include\cppunit/plugin/TestPlugInDefaultImpl.h(26) : see declaration of 'CppUnit::TestPlugInDefaultImpl'

  CommandLineParser.cpp

D:\new try\cppunit-1.12.1\include\cppunit/plugin/PlugInParameters.h(27): warning C4251: 'CppUnit::PlugInParameters::m_commandLine' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'CppUnit::PlugInParameters'

          with

          [

              _Elem=char,

              _Traits=std::char_traits,

              _Ax=std::allocator

          ]

  Generating Code...

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(D:\new try\cppunit-1.12.1\src\DllPlugInTester\.\DebugDll\DllPlugInTester.exe) does not match the Linker's OutputFile property value (D:\new try\cppunit-1.12.1\src\DllPlugInTester\DebugDll\DllPlugInTesterd_dll.exe). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(992,5): warning MSB8012: TargetName(DllPlugInTester) does not match the Linker's OutputFile property value (DllPlugInTesterd_dll). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).

LINK : fatal error LNK1181: cannot open input file 'cppunitd_dll.lib'

 

Build FAILED.

 

Time Elapsed 00:00:04.54

------ Build started: Project: TestPlugInRunner, Configuration: Debug Win32 ------

Build started 2013-1-22 11:21:15.

InitializeBuildStatus:

  Creating ".\Debug\TestPlugInRunner.unsuccessfulbuild" because "AlwaysCreate" was specified.

CustomBuild:

  Updating D:\new try\cppunit-1.12.1\lib\cppunitd_dll.dll

  系统找不到指定的文件。

C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(151,5): error MSB6006: "cmd.exe" exited with code 1.

解决:该工程还不完善

Build FAILED.

 

Time Elapsed 00:00:00.17

========== Build: 0 succeeded, 5 failed, 0 up-to-date, 0 skipped ==========

 

 

C++ 单元测试cppunit问题 fatal error C1083: Cannot open include file: 'cppunit/Portability.h': No such file or directory,

解决办法:在工程属性的Vc++ directories ——include 和library 中添加cppunit的include 和lib的路径
 
我用vs2008编写一个单元测试的控制台用来测试我写的Dll是否可用,但编译老是通不过,出现fatal error C1083: Cannot open include file: 'cppunit/Portability.h': No such file or directory,我已经把cppunit整个都拷到了编译的文件夹里了,这到底是什么原因呢?我把'cppunit/Portability.h'改成'../cppunit/Portability.h'出现了类似的错误,等我把全部相关的都改完就变成了很多“ error LNK2019: unresolved external symbol..................”,网上找到了许多,但都解决不了问题,有哪位大侠能提供解决方法?
 
应该是环境的问题,看看以下步骤是否有参考意义:
先下个最新版cppunit-1.12.1.tar.gz 解压缩,进入cppunit-1.12.1\src目录,就是源代码所在,打开CppUnitLibraries.dsw工程,是用vc6.0写的,转换到CppUnitLibraries.sln OK,接着只需要修改一点点内容,删除掉解决方案下的DSPlugIn工程,修改TestRunner下UserInterface\DynamicWindow\MsDevCallerListCtrl.cpp文件第67行,改成"#import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("8.0") lcid("0") raw_interfaces_only named_guids"。这样就可以了,点解决方案里的生成解决方案,等等等等.... 
终于好了,生成文件自动拷贝到上级目录的lib下,一共7个文件,除了原始里面那个。(用debug或release都可以的,默认是debug)
把cppunit-1.12.1\include加到vs里的选择“选项”标签里的包含文件,cppunit-1.12.1\lib加到库文件,lib想加到环境变量里也行,那样不用拷贝dll文件。
接着新建一个测试gui界面的vs c++2008 MFC对话框工程CSS_CPPUNIT,修改项目属性里的配置属性里的链接器,启动增量链接改为否。 修改CSS_CPPUNIT.cpp文件,改成这样
#include "stdafx.h"
    #include "CSS_CPPUNIT.h"
    #include "CSS_CPPUNITDlg.h"

#include 
    #include 

这里再加上这句

BOOL CCSS_CPPUNITApp::InitInstance()
    {
        #pragma comment(lib, "cppunitd.lib")
        #pragma comment(lib, "testrunnerud.lib")

把下面的注释掉

 //CCSS_CPPUNITDlg dlg;
     //m_pMainWnd = &dlg;
     //INT_PTR nResponse = dlg.DoModal();
     //if (nResponse == IDOK)
    //{
    // // TODO: 在此放置处理何时用
    // //  “确定”来关闭对话框的代码
    //}
    //else if (nResponse == IDCANCEL)
    //{
    // // TODO: 在此放置处理何时用
    // //  “取消”来关闭对话框的代码
   //}

然后在其后添加

 CppUnit::MfcUi::TestRunner runner;
      CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
      runner.addTest(registry.makeTest());
     runner.run();
    return true;
完成了,编译一下看看,界面出来了,试试看这个测试工具吧。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值