Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Started with UnitTest++

This is the current code I have from their fundamental example: http://unittest-cpp.sourceforge.net/UnitTest++.html

#include <unittest++/UnitTest++.h>

TEST(FailSpectacularly)
{
    CHECK(false);
}

int main() {
    return UnitTest::RunAllTests();
}

The include exists but I'm receiving errors: undefined reference to UnitTest::Test::* and UnitTest::* where * is some arbitrary class/method within the UnitTest++ library.

How can I get this to compile properly?

like image 928
Gio Borje Avatar asked May 07 '11 19:05

Gio Borje


2 Answers

Found the answer here: http://comments.gmane.org/gmane.comp.lang.c%2B%2B.unittest%2B%2B.devel/13

Set the library path -L/usr/include and the library -lunittest++

like image 197
Gio Borje Avatar answered Oct 15 '22 04:10

Gio Borje


Mainly for my future reference but I sorted by linking to the library last.

g++ test.cpp -lunittest++
like image 34
regomodo Avatar answered Oct 15 '22 06:10

regomodo