Ich denke, ich vermisse etwas wirklich dumm hier.Wie verbinde ich mich mit cppunit?
Ich habe libcppunit installiert: (Ich bin mit Ubuntu 12,04)
$ apt-cache policy libcppunit-dev
libcppunit-dev:
Installed: 1.12.1-4
Candidate: 1.12.1-4
Version table:
*** 1.12.1-4 0
500 http://archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
100 /var/lib/dpkg/status
$ apt-cache policy libcppunit-1.12-1
libcppunit-1.12-1:
Installed: 1.12.1-4
Candidate: 1.12.1-4
Version table:
*** 1.12.1-4 0
500 http://archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
100 /var/lib/dpkg/status
Und ich habe einen einfachen Test:
#include <iostream>
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
int main() {
CppUnit::Test* suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
CppUnit::TextUi::TestRunner runner;
runner.addTest(suite);
runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), std::cerr));
return runner.run() ? 0 : 1;
}
Und ich dies ist der Compiler Ausgabe:
$ g++ -lcppunit -o test.bin test.cpp
/tmp/ccoQDuGC.o: In function `main':
test.cpp:(.text+0x36): undefined reference to `CppUnit::TestFactoryRegistry::getRegistry(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
test.cpp:(.text+0x75): undefined reference to `CppUnit::TextTestRunner::TextTestRunner(CppUnit::Outputter*)'
test.cpp:(.text+0x8b): undefined reference to `CppUnit::TestRunner::addTest(CppUnit::Test*)'
test.cpp:(.text+0x9a): undefined reference to `CppUnit::TextTestRunner::result() const'
test.cpp:(.text+0xe2): undefined reference to `CppUnit::CompilerOutputter::CompilerOutputter(CppUnit::TestResultCollector*, std::basic_ostream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
test.cpp:(.text+0xf4): undefined reference to `CppUnit::TextTestRunner::setOutputter(CppUnit::Outputter*)'
test.cpp:(.text+0x150): undefined reference to `CppUnit::TextTestRunner::run(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, bool, bool)'
test.cpp:(.text+0x189): undefined reference to `CppUnit::TextTestRunner::~TextTestRunner()'
test.cpp:(.text+0x227): undefined reference to `CppUnit::TextTestRunner::~TextTestRunner()'
collect2: ld returned 1 exit status
Um sicherzustellen, dass die Bibliotheken existieren unter/usr/lib
$ ls /usr/lib/ | grep cppunit
libcppunit-1.12.so.1
libcppunit-1.12.so.1.0.0
libcppunit.a
libcppunit.la
libcppunit.so
Was fehlt mir, was das verursacht?
Eine Arbeit um die ich gefunden habe ist zu platzieren "-Wl, - no-as-needed" vor "-lcppunit" – Naddiseo