c - "undefined reference to `_cmocka_run_group_tests'" when running sample CMocka test -
i installed cmocka testing framework , tried sample code:
#include <stdarg.h> #include <stddef.h> #include <setjmp.h> #include <cmocka.h> /* test case nothing , succeeds. */ static void null_test_success(void **state) { (void) state; /* unused */ } int main(void) { const struct cmunittest tests[] = { cmocka_unit_test(null_test_success), }; return cmocka_run_group_tests(tests, null, null); }
but when try compile following error:
$ gcc -o tests tests.c /tmp/ccbwaxrr.o: in function `main': tests.c:(.text+0x5e): undefined reference `_cmocka_run_group_tests' collect2: error: ld returned 1 exit status
what missing?
including header files provides forward declaration of functions. function definitions, need link library.
you can use -l
option gcc
link required libarary. may need use -l
option provide path library.
Comments
Post a Comment