为什么不AUTOCONF通过AC_CHECK_HEADER测试时的.h文件是可清楚? [英] Why doesn't autoconf pass the AC_CHECK_HEADER test when the .h is file clearly available?

查看:1398
本文介绍了为什么不AUTOCONF通过AC_CHECK_HEADER测试时的.h文件是可清楚?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个时间让熊autoconf去检查一个特定的头文件的presence。

I am having a bear of a time getting autoconf to check for the presence of a particular header file.

让我们称之为头依赖inky.h,让我们说,漆黑的是已安装(单独)库与preFIX设置为在/ usr /地方。这样就把inky.h在/usr/local/inky/inky.h和libinky.so在/ usr / local / lib目录。

Let's call the header dependency "inky.h", and let's say that inky is a library that was installed (seperately) with the prefix set to "/usr/local". This put "inky.h" in /usr/local/inky/inky.h and libinky.so in /usr/local/lib.

现在,我试图验证inky.h的presence在我的应用程序configure.ac如下:

Now, I'm trying to verify the presence of inky.h in my applications configure.ac as follows:

dnl # Setup temp LDFLAGS and look for inky library/header
LDFLAGS_SAVE=${LDFLAGS};
CPPFLAGS_SAVE=${CPPFLAGS};

dnl # Look for inky on the user specified inky install path
LDFLAGS ="-L${inky_library_path}";
CPPFLAGS="-I${inky_include_path}/inky";

AC_MSG_NOTICE([Looking for inky.h using: ${CPPFLAGS}]);

dnl # This check finds inky.h just fine.  This check was only used for debugging
AC_CHECK_FILE(
   [${inky_include_path}/inky/inky.h],
   [AC_MSG_NOTICE([Found inky.h])],
   [AC_MSG_NOTICE([Didn't find inky.h])]
   )

dnl # Look for the inky header file.  If it isn't found, terminate.
AC_CHECK_HEADER(inky.h,
    [],
    [AC_MSG_ERROR([Couldn't find or include inky.h])]
    )

这将产生从的./configure以下输出(一个autoreconf -vfi后):

This produces the following output from ./configure (after an autoreconf -vfi):

configure: Looking for inky.y in fetk include path: -I/usr/local/include/inky.y
checking for /usr/local/include/inky/inky.h... yes
configure: Found inky.h
checking inky.h usability... no
checking inky.h presence... yes
configure: WARNING: inky.h: present but cannot be compiled
configure: WARNING: inky.h:     check for missing prerequisite headers?
configure: WARNING: inky.h: see the Autoconf documentation
configure: WARNING: inky.h:     section "Present But Cannot Be Compiled"
configure: WARNING: inky.h: proceeding with the compiler's result
checking for inky.h... no
configure: error: Couldn't find or include inky.h

现在,这似乎是如此,因为inky.h包括另外2头,于是我将它们添加在AC_CHECK_HEADER的第四个参数,像这样:

Now, this appears to be the case because inky.h includes 2 other headers, so I add them in on the fourth parameter of AC_CHECK_HEADER like so:

dnl # Look for the inky header file.  If it isn't found, terminate.
AC_CHECK_HEADER(inky.h,
    [],
    [AC_MSG_ERROR([Couldn't find or include inky.h])],
    [dinky.h plinky.h]
    )

这使得从./configure它能输出

Which renders this output from ./configure:

configure: Looking for inky in fetk include path: -I/usr/local/include/inky
checking for /usr/local/include/inky/inky.h... yes
configure: Found inky.h
checking for inky.h... no
configure: error: Couldn't find or include inky.h

我在我的智慧与autoconf的结束。有没有人有我要去哪里错在这里的任何想法。是否有可能得到配置,以提供关于什么是失败的更多细节?为什么我能找到该文件本身,而是宏观AC_CHECK_HEADER失败?

I'm at my wits end with autoconf. Does anyone have any idea where I'm going wrong here. Is it possible to get configure to provide more details about what is failing? Why can I find the file itself, but the AC_CHECK_HEADER macro fails?

另外,请别告诉我用不同的包分发套件。我绝不会选择的Autoconf自己,但我确实有一些依赖添加到pre-现有的项目。

Also, please don' tell me to use a different package distribution suite. I would never have chosen Autoconf myself, but I do have to add some dependencies to a pre-existing project.

另外请注意,实际库不是命名为漆黑。然而,有一种只有官方使用这个项目的问题,所以我已经改变了名称,以保护...好,保护自己!

Also note that the actual library is not named "inky." However, there is an issue of "official use only" for this project, so I have changed the names to protect the...well, to protect myself!


想通了这个问题。见我的答案。

Figured out the problem. See my answer.

推荐答案

我发现了什么问题了。那我一起工作的库是一个C ++库,但漆黑库,我链接到的是一个C ++库。所以,语言( AC_LANG )被设置为C的configure.ac脚本月初。虽然漆黑执行检查,我需要改变语言为C ++这样的Autoconf使用的C ++编译器,而不是C编译器。这是通过使用做了相当容易:

I found what the issue was. The library that I am working with is a C library, but the "inky" library that I am linking against is a C++ library. So, the language (AC_LANG) was set to C early in the configure.ac script. While performing checks for "inky", I needed to change the language to C++ so that Autoconf used the C++ compiler instead of the C compiler. This was done rather easily by using:

AC_LANG_PUSH([C++])
dnl # Do the checks for inky
AC_LANG_POP([C++])

这既解决了,我在这个线程问起这个问题,并且在我hand't尚未公布,其中我无法让 AC_CHECK_LIB 宏来工作。

This solved both the problem that I asked about in this thread, and on that I hand't posted yet wherein I couldn't get the AC_CHECK_LIB macro to work.

谢谢大家对您的输入。

Thank you everyone for your input.

这篇关于为什么不AUTOCONF通过AC_CHECK_HEADER测试时的.h文件是可清楚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆