Netbean 集成 CppUnit 问题_C/C++_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > C/C++ > Netbean 集成 CppUnit 问题

Netbean 集成 CppUnit 问题

 2010/12/23 8:03:23  myrev  http://myrev.javaeye.com  我要评论(0)
  • 摘要:当使用Netbean搭配C++插件开发时,如果使用CppUnit进行测试,每添加一个测试有一定概率会破坏Makefile文件,导致找不到CppUnit:/home/programmer/workspace/InterviewTest/CppInterview/tests/SortClass.cpp:38:undefinedreferenceto`CppUnit::SourceLine::SourceLine(std::basic_string<char,std:
  • 标签:net 问题

当使用Netbean搭配C++插件开发时,如果使用CppUnit进行测试,每添加一个测试有一定概率会破坏Makefile文件,导致找不到CppUnit:

?

/home/programmer/workspace/InterviewTest/CppInterview/tests/SortClass.cpp:38: undefined reference to `CppUnit::SourceLine::SourceLine(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
/home/programmer/workspace/InterviewTest/CppInterview/tests/SortClass.cpp:38: undefined reference to `CppUnit::SourceLine::~SourceLine()'
/home/programmer/workspace/InterviewTest/CppInterview/tests/SortClass.cpp:38: undefined reference to `CppUnit::SourceLine::~SourceLine()'
build/Debug/GNU-Linux-x86/tests/tests/SortClass.o: In function `SortClass::getTestNamer__()':
/home/programmer/workspace/InterviewTest/CppInterview/tests/SortClass.h:14: undefined reference to `CppUnit::TestNamer::TestNamer(std::type_info const&)'
/home/programmer/workspace/InterviewTest/CppInterview/tests/SortClass.h:14: undefined reference to `CppUnit::TestNamer::~TestNamer()'
build/Debug/GNU-Linux-x86/tests/tests/SortClass.o: In function `~TestSuiteBuilderContext':
/usr/include/cppunit/extensions/TestSuiteBuilderContext.h:101: undefined reference to `CppUnit::TestSuiteBuilderContextBase::~TestSuiteBuilderContextBase()'
/usr/include/cppunit/extensions/TestSuiteBuilderContext.h:101: undefined reference to `CppUnit::TestSuiteBuilderContextBase::~TestSuiteBuilderContextBase()'
build/Debug/GNU-Linux-x86/tests/tests/SortClass.o: In function `SortClass::addTestsToSuite(CppUnit::TestSuiteBuilderContextBase&)':
/home/programmer/workspace/InterviewTest/CppInterview/tests/SortClass.h:16: undefined reference to `CppUnit::TestSuiteBuilderContextBase::getTestNameFor(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/home/programmer/workspace/InterviewTest/CppInterview/tests/SortClass.h:16: undefined reference to `CppUnit::TestSuiteBuilderContextBase::addTest(CppUnit::Test*)'
build/Debug/GNU-Linux-x86/tests/tests/SortClass.o: In function `SortClass::suite()':

?

?

这是Netbean的issue,它会自动把一些运行测试时的-lcppunit参数删除了。

?

解决方法

?

打开nbproject/Makefile-Debug.mk,在.build-tests-conf: .build-conf ${TESTFILES}以下的每个${LDLIBSOPTIONS}后面加上 -lcppunit 参数

?

?

------------------------------------------------

.build-tests-conf: .build-conf ${TESTFILES}

${TESTDIR}/TestFiles/f1: ${TESTDIR}/tests/SortClass.o ${TESTDIR}/tests/testrunnerone.o ${OBJECTFILES:%.o=%_nomain.o}

${MKDIR} -p ${TESTDIR}/TestFiles

${LINK.cc} -o ${TESTDIR}/TestFiles/f1 $^ ${LDLIBSOPTIONS} -lcppunit

?

?

每添加一个测试有一定概率会自动删除-lcppunit参数,所以需要手动加上去,等后续的netbean C++插件解决吧。

?

?

?

?

?

发表评论
用户名: 匿名