configure.ac:库和头文件不可用并且不存在 [英] configure.ac: Library and headers not usable and not present

查看:353
本文介绍了configure.ac:库和头文件不可用并且不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在C中实现了一个日志记录库(我将其命名为liblogger),并使用Autotools对其进行编译和安装.据我所知,安装正确完成了,因为标头和库本身(我目前捆绑到静态库中)已安装到相应的目录(/usr/local/include/liblogger/中,用于标头和.a)的/usr/local/lib.

现在,我正在尝试将另一个工具与该库链接(也可以使用Autotools进行编译和构建).要检查日志库是否存在,我已经在这里中进行了跟踪创建configure.ac文件.但是生成的配置脚本显示:

正在检查/usr/local/include/liblogger/logger.h的可用性...否

检查/usr/local/include/liblogger/logger.h是否存在...否

正在检查/usr/local/include/liblogger/logger.h ...否

在-l/usr/local/lib/liblogger.a中检查log_init ....否

即使存在命名文件 DO .

configure.ac文件中用于检查标题和库的部分如下:

LIBLOGGER=/usr/local/lib
HEADERLOGGER=/usr/local/include/liblogger

AC_CHECK_HEADER([${HEADERLOGGER}/logger.h],
    [AC_DEFINE([HAVE_LOGGER_H], [1], [found logger.h])
    CFLAGS="$CFLAGS -I${HEADERLOGGER}"])

AC_CHECK_LIB([${LIBLOGGER}/liblogger.a],
    log_init, [found liblogger.a], [], [])

AC_SUBST(LIBLOGGER)

实际上,如果我尝试:

AC_CHECK_FILE(
   [${HEADERLOGGER}/logger.h],
   [AC_MSG_NOTICE([Found logger.h])],
   [AC_MSG_NOTICE([Didn't find logger.h])]
   )

确实找到了文件.

谢谢.

解决方案

问题不在工具的configure.ac上,而是在原始记录器库中.检查运行配置脚本时生成的 config.log 文件时,一行显示:

/usr/local/include/liblogger/logger.h:22:19: fatal error: types.h: No such file or directory

所以我实际上不得不在记录器库中重新组织一些依赖关系.

实际上,将HEADERLOGGER设置为liblogger并不能解决问题,因为(我不知道为什么),未搜索"/urs/local/include/liblogger",返回

configure: error: Couldn't find liblogger/logger.h

(也许我为此忘记了一些以前的AC指令).

道德:那里的日志文件是有原因的...:-S

I have implemented a logging library in C (which I've named liblogger), and used Autotools to compile and install it. As far as I can see, the installation is correctly done, since the headers and the library itself (which I currently bundle into a static library) are installed into the appropriate directories (/usr/local/include/liblogger/ for the headers and /usr/local/lib for the .a).

Now I am trying to link another tool with that library (compiled and built also using Autotools). To check for the logging library presence, I have followed what is said here to create the configure.ac file. But the resulting configure script says:

checking /usr/local/include/liblogger/logger.h usability... no

checking /usr/local/include/liblogger/logger.h presence... no

checking for /usr/local/include/liblogger/logger.h... no

checking for log_init in -l/usr/local/lib/liblogger.a... no

even though the named files DO exist.

The part of the configure.ac file where I check for the header and the library is as follows:

LIBLOGGER=/usr/local/lib
HEADERLOGGER=/usr/local/include/liblogger

AC_CHECK_HEADER([${HEADERLOGGER}/logger.h],
    [AC_DEFINE([HAVE_LOGGER_H], [1], [found logger.h])
    CFLAGS="$CFLAGS -I${HEADERLOGGER}"])

AC_CHECK_LIB([${LIBLOGGER}/liblogger.a],
    log_init, [found liblogger.a], [], [])

AC_SUBST(LIBLOGGER)

Actually, if I try with:

AC_CHECK_FILE(
   [${HEADERLOGGER}/logger.h],
   [AC_MSG_NOTICE([Found logger.h])],
   [AC_MSG_NOTICE([Didn't find logger.h])]
   )

it does find the file.

Thanks.

解决方案

The problem was not on the tool's configure.ac, but in the original logger library. When inspecting the config.log file generated when running the configure script, there was a line saying:

/usr/local/include/liblogger/logger.h:22:19: fatal error: types.h: No such file or directory

So I actually had to reorganize some dependencies in the logger library.

In fact, setting HEADERLOGGER to liblogger doesn't solve the problem, since (I don't know why), "/urs/local/include/liblogger" is not being searched for, returning

configure: error: Couldn't find liblogger/logger.h

(Perhaps I'm forgetting some previous AC instruction for that).

The moral: the log files are there for a reason... :-S

这篇关于configure.ac:库和头文件不可用并且不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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