Netbeans Cpp 编译并运行项目,但不使用 cppunit 进行测试

Netbeans Cpp compiles and runs project, but not test with cppunit

我有一个使用 wiringPi 和 MySQL Connector 等库的 C++ 项目。我的常规项目在 运行 时正常编译。当我尝试测试我的一个测试时,它无法构建项目。

这是输出:

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/home/nick/NetBeansProjects/utest'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux/utest
make[2]: Entering directory '/home/nick/NetBeansProjects/utest'
make[2]: 'dist/Debug/GNU-Linux/utest' is up to date.
make[2]: Leaving directory '/home/nick/NetBeansProjects/utest'
make[1]: Leaving directory '/home/nick/NetBeansProjects/utest'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-tests-conf
make[1]: Entering directory '/home/nick/NetBeansProjects/utest'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux/utest
make[2]: Entering directory '/home/nick/NetBeansProjects/utest'
make[2]: 'dist/Debug/GNU-Linux/utest' is up to date.
make[2]: Leaving directory '/home/nick/NetBeansProjects/utest'
mkdir -p build/Debug/GNU-Linux/tests/TestFiles
g++ -lmysqlcppconn -lwiringPi      -o build/Debug/GNU-Linux/tests/TestFiles/f1 build/Debug/GNU-Linux/tests/tests/ConfigParserRunner.o build/Debug/GNU-Linux/tests/tests/ConfigParserTest.o build/Debug/GNU-Linux/main_nomain.o build/Debug/GNU-Linux/src/ConfigFactory_nomain.o build/Debug/GNU-Linux/src/DatabaseAdapter_nomain.o build/Debug/GNU-Linux/src/MatrixControl_nomain.o build/Debug/GNU-Linux/src/ModuleEntity_nomain.o build/Debug/GNU-Linux/src/ModuleServer_nomain.o build/Debug/GNU-Linux/src/SerialDriver_nomain.o build/Debug/GNU-Linux/src/StorageManagement_nomain.o -Llib/cpputest-3.8/lib -L/usr/lib/mysql -L/usr/lib/x86_64-linux-gnu -L/usr/include/cppconn -L/usr/include/cppunit -lCppUTest -lCppUTestExt `cppunit-config --libs`   
build/Debug/GNU-Linux/src/DatabaseAdapter_nomain.o: In function `DatabaseAdapter::DatabaseAdapter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
/home/nick/NetBeansProjects/utest/src/DatabaseAdapter.cxx:8: undefined reference to `get_driver_instance'
build/Debug/GNU-Linux/src/DatabaseAdapter_nomain.o: In function `DatabaseAdapter::addProduct(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, productData, int)':
/home/nick/NetBeansProjects/utest/src/DatabaseAdapter.cxx:27: undefined reference to `get_driver_instance'
build/Debug/GNU-Linux/src/DatabaseAdapter_nomain.o: In function `DatabaseAdapter::getEntriesByModule(int)':
/home/nick/NetBeansProjects/utest/src/DatabaseAdapter.cxx:66: undefined reference to `get_driver_instance'
build/Debug/GNU-Linux/src/MatrixControl_nomain.o: In function `MatrixControl::MatrixControl(ModuleServer*)':
/home/nick/NetBeansProjects/utest/src/MatrixControl.cpp:23: undefined reference to `wiringPiSetup'
build/Debug/GNU-Linux/src/SerialDriver_nomain.o: In function `SerialDriver::SerialDriver()':
/home/nick/NetBeansProjects/utest/src/SerialDriver.cpp:18: undefined reference to `pinMode'
/home/nick/NetBeansProjects/utest/src/SerialDriver.cpp:19: undefined reference to `pinMode'
/home/nick/NetBeansProjects/utest/src/SerialDriver.cpp:20: undefined reference to `pinMode'
build/Debug/GNU-Linux/src/SerialDriver_nomain.o: In function `SerialDriver::sendShiftData(unsigned char)':
/home/nick/NetBeansProjects/utest/src/SerialDriver.cpp:28: undefined reference to `shiftOut'
build/Debug/GNU-Linux/src/SerialDriver_nomain.o: In function `SerialDriver::setLatch(bool)':
/home/nick/NetBeansProjects/utest/src/SerialDriver.cpp:33: undefined reference to `digitalWrite'
collect2: error: ld returned 1 exit status
nbproject/Makefile-Debug.mk:146: recipe for target 'build/Debug/GNU-Linux/tests/TestFiles/f1' failed
make[1]: *** [build/Debug/GNU-Linux/tests/TestFiles/f1] Error 1
make[1]: Leaving directory '/home/nick/NetBeansProjects/utest'
nbproject/Makefile-impl.mk:67: recipe for target '.build-tests-impl' failed
make: *** [.build-tests-impl] Error 2

BUILD TESTS FAILED (exit value 2, total time: 584ms)

用于在 DatabaseAdapter 和 SerialDriver 实施之前工作的测试 类。

我已将库选项添加到我的主项目属性中的链接器附加选项,如下所示:

-lCppUTest -lCppUTestExt -lwiringPi -lpthread -lmysqlclient -lmysqlcppconn -lcppunit -ldl

我的链接有问题吗?

编辑:我尝试测试的测试没有使用任何失败的 类。

提前致谢。

解决方案是将我的依赖项作为选项添加到我的库文件夹中。我在链接器中添加了 -lwiringPi 和 -lmysqlcppconn。