I am trying to compile the following test application using CodeBlocks and CppUTest, however no matter what I do I always get the undefined reference
error. I compiled CppUTest with cygwin, in codeblocks I use MinGW.
The project directory just has two files, main.cpp
and tests.cpp
, I am trying to get this to compile.
This is the main.cpp
file:
#include "CppUTest/CommandLineTestRunner.h"
int main(int ac, char** av)
{
return CommandLineTestRunner::RunAllTests(ac, av);
}
This is the tests.cpp
file:
#include "CppUTest/TestHarness.h"
TEST_GROUP(FirstTestGroup)
{
};
TEST(FirstTestGroup, FirstTest)
{
FAIL("Fail me!");
}
TEST(FirstTestGroup, SecondTest)
{
STRCMP_EQUAL("hello", "world");
LONGS_EQUAL(1, 2);
CHECK(false);
}
I already have the libraries libCppUTest.a
and libCppUTestExt.a
, now I have to link them to the project. For this I've attempted the following:
- In build options, add
<CppUTest>\include\
to search directories for the compiler. - In build options, add
<CppUTest>\lib\
to search directories for the linker. - In link settings, add
libCppUTest.a
andlibCppUTestExt.a
to link libraries. Also tried with the full path to these libraries.
I think the problem is not Codeblocks, because I've tried with every guide I've found to link the libraries and I always get undefined reference
. I've also tried to add these as global settings but I get the same error, undefined reference
.
Any ideas?