致命错误:找不到gnu/stubs-soft.h文件或目录

11

我在64位Ubuntu 16.04上为32位Cortex A9平台交叉编译一个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键自动补全)? - Stephen Newell
谢谢Steve,"$ source /usr/local/comp/poky/1.7/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi"可用。我可以看到该文件内启用了“-mfloat-abi = hard”。 - hal2000
2个回答

23

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

从GCC手册中:

-mfloat-abi=name:

指定要使用的浮点ABI。允许的值为:“soft”,“softfp”和“hard”。

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

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


我对这个交叉编译的东西不熟悉,在eclipse设置中应该把-m放在哪里? - Michael

1

为了确定缺失的包,运行以下命令:

sudo apt-file search stubs-soft.h

这表明包libc6-dev-armel-cross包含文件stubs-soft.h,因此可以通过命令安装缺失的软件包。

sudo apt-get install libc6-dev-armel-cross

它将为本地机器提供文件stubs-soft.h

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接