我正在尝试将Check集成到 Autotools 项目中。单个测试工作正常,但在使用套件the site explains时遇到了一些问题:
$ make check
Making check in src
Making check in .
make[1]: Nothing to be done for `check-am'.
Making check in tests
/Applications/Xcode.app/Contents/Developer/usr/bin/make elevator_test
gcc -D_THREAD_SAFE -I/usr/local/Cellar/check/0.9.14/include -g -O2 -o elevator_test elevator_test-elevator_test.o -L/usr/local/Cellar/check/0.9.14/lib -lcheck
Undefined symbols for architecture x86_64:
"_elevator_create", referenced from:
_test_elevator_create in elevator_test-elevator_test.o
_test_elevator_is_full in elevator_test-elevator_test.o
"_elevator_free", referenced from:
_test_elevator_create in elevator_test-elevator_test.o
_test_elevator_is_full in elevator_test-elevator_test.o
"_elevator_is_full", referenced from:
_test_elevator_is_full in elevator_test-elevator_test.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [elevator_test] Error 1
make[1]: *** [check-am] Error 2
make: *** [check-recursive] Error 1
这是我的测试文件:http://pastebin.com/aP341AZa。
套件代码看起来与网站完全一样,没有套件功能的运行就像魅力一样。我错过了什么?
编辑:这是我的测试Makefile.am
:
TESTS = elevator_test
check_PROGRAMS = elevator_test
elevator_test_SOURCES = elevator_test.c $(top_builddir)/src/elevator/elevator.h $(top_builddir)/src/elevator/elevator_options.h
elevator_test_CFLAGS = @CHECK_CFLAGS@
elevator_test_LDADD = @CHECK_LIBS@
我正在按照网站的建议正确添加CFLAGS
和LDADD
,并且在构建test
时可以看到以下编译标记:
-I/usr/local/Cellar/check/0.9.14/include -L/usr/local/Cellar/check/0.9.14/lib -lcheck