[英]Compiling issues with check and autotools
我有一些带有check
框架的C单元测试。
我的Makefile.am
看起来像:
check_PROGRAMS = check_fseqs
check_fseqs_SOURCES = tests/check_fseqs.c
check_fseqs_LDADD = -lcheck
文件结构为( 省略了一些文件):
.
|-- Makefile.am
|-- configure.ac
|-- src
| |-- fseqs.c
| |-- fseqs.h
| |-- fseqs.o
`-- tests
`-- check_fseqs.c
然后我运行make check
并抛出:
$ make check
/Applications/Xcode.app/Contents/Developer/usr/bin/make check_fseqs
gcc -g -O2 -o check_fseqs tests/check_fseqs.o -lcheck
Undefined symbols for architecture x86_64:
"_f_msb", referenced from:
_test_f_msb in check_fseqs.o
"_min", referenced from:
_test_min in check_fseqs.o
"_substract", referenced from:
_test_substract in check_fseqs.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[1]: *** [check_fseqs] Error 1
make: *** [check-am] Error 2
怎么了?
您缺少依赖项。 如果要构建fseqs.o,则需要将其添加为check_DEPENDENCIES
,并将其添加到check_LDADD
行中。 如果它是一个库,您将做同样的事情,指定库文件而不是组成库的所有目标文件。
check_DEPENDENCIES
位确保生成正确的规则,而check_LDADD
确保在链接时将文件添加到命令行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.