简体   繁体   English

autoconf configure导致C std lib头相关的编译错误

[英]autoconf configure results in C std lib header related compile errors

I am attempting to build a project that comes with an automake/autoconf build system. 我正在尝试构建一个带有automake / autoconf构建系统的项目。 This is a well-used project, so I'm skeptical about a problem with the configure scripts, makefiles, or code as I received them. 这是一个很常用的项目,所以我对配置脚本,makefile或代码的问题持怀疑态度。 It is likely some kind of environment, path, flag, etc problem - something on my end with simply running the right commands with the right parameters. 它可能是某种环境,路径,标志等问题 - 在我的最终只需使用正确的参数运行正确的命令。

The configuration step seems to complete in a satisfactory way. 配置步骤似乎以令人满意的方式完成。 When I run make, I'm shown a set of errors primarily of these types: 当我运行make时,我会看到一组主要是这些类型的错误:

error: ‘TRUE’ undeclared here (not in a function)
error: ‘struct work’ has no member named ‘version’
error: expected ‘)’ before ‘PRIu64’

Let's focus on the last one, which I have spent time researching - and I suspect all the errors are related to missing definitions. 让我们关注最后一个,我花时间研究 - 我怀疑所有错误都与缺少定义有关。 Apparently the print-friendly extended definitions from the C standard library header file inttypes.h is not being found. 显然,找不到C标准库头文件inttypes.h中的打印友好扩展定义。 However, in the configure step everything is claimed to be in order: 但是,在配置步骤中,声称所有内容都按顺序排列:

configure:4930: checking for inttypes.h
configure:4930: /usr/bin/x86_64-linux-gnu-gcc -c -g -O2  conftest.c >&5
configure:4930: $? = 0
configure:4930: result: yes

All the INTTYPES flags are set correctly if I look in confdefs.h, config.h, config.log Output Variables, etc: 如果我查看confdefs.h,config.h,config.log输出变量等,所有INTTYPES标志都设置正确:

HAVE_INTTYPES_H='1'
#define HAVE_INTTYPES_H 1

The problem is the same whether doing a native build, or cross-compiling (for arm-linux-gnueabihf, aka armhf). 无论是进行本机构建还是交叉编译(对于arm-linux-gnueabihf,又名armhf),问题都是一样的。

The source .c file in question does have config.h included as you'd expect, which by my understanding via the m4 macros mechanic should be adding an 有问题的源.c文件确实包含了config.h,正如您所期望的那样,根据我的理解,通过m4宏机制应该添加一个

#include <inttypes.h>

line. 线。 Yes, as you may be inclined to ask, if I enter this line myself into the .c file it appears to work and the PRIu64 errors go away. 是的,正如您可能倾向于问的那样,如果我将此行输入到.c文件中,它似乎正常工作,并且PRIu64错误消失了。

I'm left with wondering how to debug this type of problem - essentially, everything I am aware of tells me I've done the configure properly, but I'm left with a bogus make process . 我不知道如何调试这类问题 - 基本上,我所知道的一切都告诉我,我已经完成了配置,但我留下了一个虚假的制作过程 Aside from trying every ./configure tweak and trick I can find, I've started looking at the auto-generated Makefile.in itself, but nothing so far. 除了尝试我能找到的每个./configure调整和技巧之外,我已经开始查看自动生成的Makefile.in本身,但到目前为止还没有。 Also looking into how I can get the C pre-processor to tell me which header files it's actually inserting. 另外看看我如何让C预处理器告诉我它实际插入了哪些头文件。

EDIT: I've confirmed that the -DHAVE_CONFIG_H mechanic looks good through configure, config.log, Makefile, etc. 编辑:我已通过configure,config.log,Makefile等确认-DHAVE_CONFIG_H机制看起来不错。

autoconf does not automatically produce #include directives. autoconf不会自动生成#include指令。 You need to do that on your own based on the HAVE_* macros. 您需要基于HAVE_*宏自行完成此HAVE_* So you'll have to add something like this: 所以你必须添加这样的东西:

#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif

If these lines show up in confdefs.h , a temporary header file used by configure scripts, this does excuse your application from performing these #include s. 如果这些行显示在confdefs.hconfigure脚本使用的临时头文件)中,这confdefs.h您的应用程序执行这些#include If configure writes them to confdefs.h , this is solely for the benefit of other configure tests, and not for application use. 如果configure将它们写入confdefs.h ,这仅仅是为了其他configure测试的好处,而不是为了应用程序使用。

First, run make -n for the target that failed. 首先,为失败的目标运行make -n This is probably some .o file; 这可能是一些.o文件; you may need some tweaking to get its path correctly. 你可能需要一些调整来正确地获得它的路径。

Now you have the command used to compile your file. 现在您拥有用于编译文件的命令。 If you don't find the problem by meditating on this command, try to run it, adding the -E to force preprocessor output text instead of invoking the compiler. 如果通过调试此命令没有找到问题,请尝试运行它,添加-E以强制预处理器输出文本而不是调用编译器。

Note that now the .o file will be text, and you must rebuild it without -E later. 请注意,现在.o文件将是文本,您必须在不使用-E情况下重建它。

You may find some preprocessor flags useful to get more details: -dM or -dD , or others. 您可能会发现一些预处理程序标志可用于获取更多详细信息: -dM-dD或其他。

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

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