简体   繁体   English

检查和自动工具的编译问题

[英]Compiling issues with check and autotools

I have some C unit tests with check framework. 我有一些带有check框架的C单元测试。

My Makefile.am looks like: 我的Makefile.am看起来像:

check_PROGRAMS = check_fseqs
check_fseqs_SOURCES = tests/check_fseqs.c
check_fseqs_LDADD = -lcheck

File structure is (some files were omitted ): 文件结构为( 省略了一些文件):

.
|-- Makefile.am
|-- configure.ac
|-- src
|   |-- fseqs.c
|   |-- fseqs.h
|   |-- fseqs.o
`-- tests
    `-- check_fseqs.c

Then I run make check and it throws: 然后我运行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

What is wrong? 怎么了?

You're missing a dependency. 您缺少依赖项。 If you're building fseqs.o, you need to add it as check_DEPENDENCIES and also add it to your check_LDADD line. 如果要构建fseqs.o,则需要将其添加为check_DEPENDENCIES ,并将其添加到check_LDADD行中。 If it was a library, you'd do the same thing, specifying the library file instead of all of the object files making the library up. 如果它是一个库,您将做同样的事情,指定库文件而不是组成库的所有目标文件。

The check_DEPENDENCIES bit ensures the correct rule is generated, and the check_LDADD ensures the file is added to the command line while linking. check_DEPENDENCIES位确保生成正确的规则,而check_LDADD确保在链接时将文件添加到命令行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM