寄语:虽然很杂乱,但确实能解决问题
2013-1-22 11:20:11.
------ Build started: Project: cppunit, Configuration: Debug Win32 ------
Build started 2013-1-22 11:20:11.
InitializeBuildStatus:
ClCompile:
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:
PostBuildEvent:
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:
ClCompile:
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 |
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:
InitializeBuildStatus:
ClCompile:
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
PostBuildEvent:
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:
ClCompile:
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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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/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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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/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'
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'
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'
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'
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'
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'
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'
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'
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'
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:
LinkEmbedManifest:
PostBuildEvent:
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:
ClCompile:
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'
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/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'
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:
CustomBuild:
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; 完成了,编译一下看看,界面出来了,试试看这个测试工具吧。