【发布时间】:2012-05-04 16:35:18
【问题描述】:
我有一个项目使用 cppunit 进行单元测试,我使用 QTtestrunner 显示结果这里是代码
CPPUNIT_NS::QtUi::TestRunner testrunner;
testrunner.addTest (CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
testrunner.run (true);
但我在编译时有这条消息:
src/main.cpp:78: undefined reference to 'CppUnit::QtTestRunner::QtTestRunner()'
src/main.cpp:79: undefined reference to CppUnit::QtTestRunner::addTest(CppUnit::Test*)'
src/main.cpp:80: undefined reference to CppUnit::QtTestRunner::run(bool)'
src/main.cpp:91: undefined reference to 'CppUnit::QtTestRunner::~QtTestRunner()'
我知道链接有问题,但我包含了所有我需要的 libcppunit.a 和 libcppunit.so
【问题讨论】:
-
能否请您添加用于链接的命令行参数?
-
我使用 bjam 进行编译,这是我的代码
use-Library = <library-path>UT_Cpp_Test/main/libs/ <library-file>UT_Cpp_Test/main/libs/libcppunit.a;这是用于静态库的。exe UT_Cpp_Test_$(GL_OS_TAG) : [ glob src/*.cpp ] : $(usage-requirements) $(use-Library) <library-path>UT_Cpp_Test/libs <find-shared-library>cppunit和这个用于执行。 -
事实上我发现我没有编译 qttesrunnerlib,所以我在安装 qt 后尝试编译它,我需要链接到创建的库,谢谢
标签: c++ qt compiler-construction cppunit