简体   繁体   中英

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. This is a well-used project, so I'm skeptical about a problem with the configure scripts, makefiles, or code as I received them. 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:

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. 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:

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).

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

#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.

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. Also looking into how I can get the C pre-processor to tell me which header files it's actually inserting.

EDIT: I've confirmed that the -DHAVE_CONFIG_H mechanic looks good through configure, config.log, Makefile, etc.

autoconf does not automatically produce #include directives. You need to do that on your own based on the HAVE_* macros. 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. If configure writes them to confdefs.h , this is solely for the benefit of other configure tests, and not for application use.

First, run make -n for the target that failed. This is probably some .o file; 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.

Note that now the .o file will be text, and you must rebuild it without -E later.

You may find some preprocessor flags useful to get more details: -dM or -dD , or others.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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