【问题标题】:fatal error: gnu/stubs-soft.h: No such file or directory致命错误:gnu/stubs-soft.h:没有这样的文件或目录
【发布时间】:2018-03-06 20:06:13
【问题描述】:

在 32 位 Cortex A9 平台的 64 位 Ubuntu 16.04 上交叉编译 helloworld 程序时出现以下错误。

$ make
/usr/local/comp/poky/1.7/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mtune=cortex-a9 --sysroot=/usr/local/comp/poky/1.7/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi -Iinclude -Wall -O3 -c -o main.o main.c
In file included from /usr/local/comp/poky/1.7/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/features.h:389:0,
             from /usr/local/comp/poky/1.7/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/stdio.h:27,
             from main.c:5:
/usr/local/comp/poky/1.7/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/gnu/stubs.h:7:29: fatal error: gnu/stubs-soft.h: No such file or directory
# include <gnu/stubs-soft.h>
                         ^
compilation terminated.
makefile:45: recipe for target 'main.o' failed
make: *** [main.o] Error 1

然后我检查 stubs.h 文件的内容:

$ cat /usr/local/comp/poky/1.7/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/gnu/stubs.h 
/* This file is automatically generated.
   This file selects the right generated file of `__stub_FUNCTION' macros
   based on the architecture being compiled for.  */


#if !defined __ARM_PCS_VFP
# include <gnu/stubs-soft.h>
#endif
#if defined __ARM_PCS_VFP
# include <gnu/stubs-hard.h>
#endif

我应该在makefile 中定义_ARM_PCS_VFP 吗?

【问题讨论】:

  • 这是 Yocto 吗?您是否获取了 SDK 提供的环境文件(可能是 /usr/local/comp/poky/1.7/environment-something(使用 tab 补全)?
  • 感谢史蒂夫,$ source /usr/local/comp/poky/1.7/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi 工作。我可以看到该文件中启用了-mfloat-abi=hard

标签: gcc makefile cross-compiling


【解决方案1】:

根据您的交叉编译器的名称,“cortexa9hf-vfp-neon-poky-linux-gnueabi”,它针对启用了 VFP 架构和 neon 的 Cortex-A9。添加-mfloat-abi=hard开关应该可以解决问题。

来自 GCC 手册:

-mfloat-abi=名称:

指定要使用的浮点 ABI。允许的值为: “软”、“softfp”和“硬”。

指定“soft”会导致 GCC 生成包含库的输出 要求浮点运算。 “softfp”允许生成 代码使用硬件浮点指令,但仍使用 软浮点调用约定。 “硬”允许生成 浮点指令并使用特定于 FPU 的调用约定。

默认值取决于具体的目标配置。注意 硬浮点和软浮点 ABI 不兼容链接;你必须 用相同的 ABI 编译你的整个程序,并用 兼容的库集。

【讨论】:

  • 我是这个交叉编译器的新手,在 Eclipse 设置中我应该把 -m 放在哪里?
猜你喜欢
  • 1970-01-01
  • 2016-01-08
  • 1970-01-01
  • 2014-05-25
  • 2017-05-09
  • 2021-05-15
  • 2014-10-31
  • 2022-01-11
  • 2021-09-19
相关资源
最近更新 更多