Reputation: 121
I'm working on a project and i have recently convinced myself that i should continue in an testdriven approach. Mainly because the project itself is growing and i want proof of that all functions work.
But i bump into some problems while doing a cunit tutorial. http://cunit.sourceforge.net/doc/writing_tests.html
This is my cunit test file :
#include <CUnit/CUnit.h>
main(){
test_maxi();
}
int maxi(int i1, int i2){
return (i1 > i2) ? i1 : i2;
}
void test_maxi(void){
CU_ASSERT(maxi(0,2) == 2);
CU_ASSERT(maxi(0,-2) == 0);
CU_ASSERT(maxi(2,2) == 2);
}
i get these errors when i try to compile it :
testtest.c:(.text+0x62): undefined reference to
CU_assertImplementation' testtest.c:(.text+0x9b): undefined reference to
CU_assertImplementation' testtest.c:(.text+0xd5): undefined reference to `CU_assertImplementation' collect2: ld returned 1 exit status
I used google and i think it got something todo with linking? But i didnt get much help out of it.
Best Regards Rickard
Upvotes: 2
Views: 5085
Reputation: 38717
Solution by OP.
compiled it using:
gcc -Wall -o test basicexample.c -lcunit
Upvotes: 1