Importing CUnit sources

9.4k Views Asked by At

i'm having a problem to use Unit test in C, i've tried to install CUnit in my computer and after include the lib.

i've followed steeps to install the CUnit:

1 - download the sources
2 - configure it using "./configure --prefix='/lib' "
3 - make (only make)
4 - sudo make install

and this is my test source file, it's not making tests, but i can't compile this, i got this error before "CUnit.h: No such file or directory":

#include "CUnit.h"
#include <stdlib.h>
#include <stdio.h>

int main(){


    print("Hello");

    return 0;
}

I want to know, how can i install CUnit to use in my test source files!

Thanks in advance.

EDIT

HAHA, i got this!

i just run configure without parameters, like that:

"./configure"
2

There are 2 best solutions below

2
On

As shown in the code example you should use something like this :

#include <CUnit/CUnit.h>

because every CUnit includes are located in a CUnit subdirectory (in general in /usr/local/include/CUnit)

0
On

What about adding -I/lib/include flag to include header files installed in /lib/include/CUnit and -lcunit -L/lib/CUnit/lib for linking with the installed libraries?

gcc test_file_source.c -I/lib/include -lcunit -L/lib/CUnit/lib -o testing