问题描述
在64位Ubuntu 16.04上针对32位Cortex A9平台交叉编译helloworld程序时遇到以下错误.
I had the below error while cross compiling a helloworld program on 64 bit Ubuntu 16.04, for 32 bit Cortex A9 platform.
$ 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文件的内容:
Then I examine the content of the stubs.h file:
$ 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
吗?
Shall I define the _ARM_PCS_VFP
in the makefile?
推荐答案
从交叉编译器的名称"cortexa9hf-vfp-neon-poky-linux-gnueabi"开始,它针对具有VFP架构和neon的Cortex-A9.已启用.添加-mfloat-abi=hard
开关应该可以解决该问题.
From the name of your cross compiler, "cortexa9hf-vfp-neon-poky-linux-gnueabi", it targets the Cortex-A9 with VFP architecture and neon enabled. Adding -mfloat-abi=hard
switch should solve the problem.
-mfloat-abi =名称:
-mfloat-abi=name:
指定要使用的浮点ABI.允许的值为: "soft","softfp"和"hard".
Specifies which floating-point ABI to use. Permissible values are: ‘soft’, ‘softfp’ and ‘hard’.
指定软"会导致GCC生成包含库的输出 要求进行浮点运算. "softfp"允许生成 代码使用硬件浮点指令,但仍使用 软浮动调用约定. 硬"允许生成 浮点指令,并使用特定于FPU的调用约定.
Specifying ‘soft’ causes GCC to generate output containing library calls for floating-point operations. ‘softfp’ allows the generation of code using hardware floating-point instructions, but still uses the soft-float calling conventions. ‘hard’ allows generation of floating-point instructions and uses FPU-specific calling conventions.
默认值取决于特定的目标配置.注意 硬浮和软浮ABI不兼容链接;你必须 使用相同的ABI编译整个程序,并与 兼容的库集.
The default depends on the specific target configuration. Note that the hard-float and soft-float ABIs are not link-compatible; you must compile your entire program with the same ABI, and link with a compatible set of libraries.
这篇关于致命错误:gnu/stubs-soft.h:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!