C 自动工具,如果找不到交叉编译器,如何失败
我用autoconf/automake做了一个小项目 本项目拟同时进行本机编译和交叉编译,例如:C 自动工具,如果找不到交叉编译器,如何失败,c,autotools,C,Autotools,我用autoconf/automake做了一个小项目 本项目拟同时进行本机编译和交叉编译,例如: ./configure --host=arm-none-eabi 这个很好用。但有一个问题是,如果没有安装交叉编译器,则配置的脚本会忽略它,并使用已安装的默认编译器(例如 ./configure --host=arm-none-eabi checking for a BSD-compatible install... /usr/bin/install -c checking whether bui
./configure --host=arm-none-eabi
这个很好用。但有一个问题是,如果没有安装交叉编译器,则配置的脚本会忽略它,并使用已安装的默认编译器(例如
./configure --host=arm-none-eabi
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-none-eabi-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking whether make sets $(MAKE)... (cached) yes
checking for arm-none-eabi-gcc... no
checking for gcc... gcc
checking whether the C compiler works... yes
此处未找到arm none eabi gcc。但它会找到本机gcc,并继续使用本机编译器
如果我使用--host=XXXX请求交叉编译,并且找不到编译器,我可以在configure.ac中放入什么使configure脚本停止并出错?当您指定--host=
时,该值与运行配置.guess
脚本的结果不同,autoconf
进入模式。具体而言,变量交叉编译
设置为yes
如果配置脚本处于“交叉编译”模式,则无法运行任何生成的可执行文件,因此无法判断生成的二进制文件是否为有效的“主机”二进制文件。据推测,一个包含文件值的大型数据库可能能够判断是否生成了有效的主机二进制文件。尽管autotools内置了几十年的经验,但仍存在一些组合问题,它们永远无法跟上所有可能的体系结构和ABI
autoconf
C编译器检查编译器(即$CC
)是否可以生成可执行文件<如果编译器没有主机三元组作为前缀,例如,arm none-eabi-gcc
,则code>autoconf可能会提供警告,但如果它找到一个工作的编译器,例如本机gcc
,则不会“失败”
因此,确保使用正确编译器进行交叉编译的唯一方法是指定编译器:
/configure--host=arm none eabi CC=“arm none eabi gcc”
如果此编译器无法生成可执行文件,则配置脚本将失败