我安装了CMocka 测试框架并尝试了示例代码:
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
/* A test case that does nothing and 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);
}
但是当我尝试编译时,出现以下错误:
$ gcc -o Tests tests.c
/tmp/ccbwAXrr.o: In function `main':
tests.c:(.text+0x5e): undefined reference to `_cmocka_run_group_tests'
collect2: error: ld returned 1 exit status
我错过了什么?