I had the below error while cross compiling a helloworld program on 64 bit Ubuntu 16.04, for 32 bit Cortex A9 platform.
當我在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
^
compilation terminated.
makefile:45: recipe for target 'main.o' failed
make: *** [main.o] Error 1
Then I examine the content of the stubs.h file:
然后我檢查存根的內容。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
#endif
#if defined __ARM_PCS_VFP
# include
#endif
Shall I define the _ARM_PCS_VFP in the makefile?
我要在makefile中定義_ARM_PCS_VFP嗎?
1 个解决方案
#1
2
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.
從交叉編譯器的名稱“cortexa9hf- VFP -ne - ton -poky-linux-gnueabi”中,它以啟用VFP架構和neon- a9為目標。增加-mfloat-abi=硬開關應該可以解決這個問題。
From GCC manual:
從GCC手冊:
-mfloat-abi=name:
-mfloat-abi =名稱:
Specifies which floating-point ABI to use. Permissible values are: ‘soft’, ‘softfp’ and ‘hard’.
指定使用哪個浮點ABI。允許的值是:“soft”、“softfp”和“hard”。
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.
指定“soft”會導致GCC生成包含浮點操作的庫調用的輸出。“softfp”允許使用硬件浮點指令生成代碼,但仍然使用軟浮點調用約定。“硬”允許生成浮點指令,並使用特定於fpu的調用約定。
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.
缺省值取決於特定的目標配置。注意,硬浮點數和軟浮點數ABIs不兼容鏈接;您必須使用相同的ABI編譯整個程序,並使用兼容的庫集進行鏈接。