binutils/bfd.h现在需要config.h吗?

binutils/bfd.h现在需要config.h吗?,c,linux,gcc,binutils,C,Linux,Gcc,Binutils,我正在尝试使用BFD库,因此我安装了packagebinutils dev,其中包括: #include <bfd.h> …我应该包括config.h-但我没有使用autoconf 我是否包含了错误的头文件?您应该如何使用binutils-dev 下面是一个演示程序: #include <stdio.h> #include <bfd.h> int main() { bfd_init(); bfd* file = bfd_openr("a.

我正在尝试使用BFD库,因此我安装了package
binutils dev
,其中包括:

#include <bfd.h>
…我应该包括
config.h
-但我没有使用autoconf

我是否包含了错误的头文件?您应该如何使用binutils-dev

下面是一个演示程序:

#include <stdio.h>
#include <bfd.h>

int main()
{
    bfd_init();

    bfd* file = bfd_openr("a.out", 0);

    if (!file)
        return -1;

    if (bfd_check_format(file, bfd_object))
        printf("object file\n");
    else
        printf("not object file\n");

    bfd_close(file);

    return 0;
}

嗯,使用页眉的最正确方法是在包中使用自动工具。有些人很固执,我认为你对此无能为力

另一种方法是通过定义正在使用的宏来绕过检查:

#define PACKAGE 1
#define PACKAGE_VERSION 1
当然,如果您已经定义了这些值,您也可以将它们设置为一些合理的值,如:

#define PACKAGE "your-program-name"
#define PACKAGE_VERSION "1.2.3"
并将其用于您的程序。你通常会在某个时候使用类似的东西来保持版本的一致性

如果您使用的是符合标准的编译器,这就足够了,因为这样会声明
\uuuu STDC\uuuu
宏,一切都会正常进行。好的,只要您使用的头文件不需要更多的autoconf生成定义

例如,如果您想使用
plugin api.h
,您实际上必须处理
stdint.h
inttypes.h
相关的检查:
#define PACKAGE 1
#define PACKAGE_VERSION 1
#define PACKAGE "your-program-name"
#define PACKAGE_VERSION "1.2.3"