floating-point - 利用 -mfloat-abi=hard 和 -mfpu=vfp/neon Codesourcery Lite 2013.05-24

标签 floating-point embedded arm cross-compiling codesourcery

为了使用 vfp 或 neon,我在交叉编译中添加了 -mfpu=vfp 和 -mfloat-abi=hard。该程序是一个非常简单的 hellofloat.cpp,然后不再使用 Sourcery CodeBench Lite 2013.05-24 进行编译。

#include <string>
#include <iostream>
using namespace std;
int main()
{
    double val=1.04;
    cout << "Hello Float: " << val  << endl;
}

编译指令:
arm-none-linux-gnueabi-g++ -o armhf-main main.cpp  -march=armv7-a  -mfloat-abi=hard -mfpu=neon

我很困惑,因为 Codesorcery 应该支持 armhf 编译?

错误:
In file included from /home/user/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/../arm-none-linux-gnueabi/libc/usr/include/features.h:399:0,
                 from /home/user/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/../lib/gcc/arm-none-linux-gnueabi/4.7.3/../../../../arm-none-linux-gnueabi/include/c++/4.7.3/arm-none-linux-gnueabi/bits/os_defines.h:40,
                 from /home/user/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/../lib/gcc/arm-none-linux-gnueabi/4.7.3/../../../../arm-none-linux-gnueabi/include/c++/4.7.3/arm-none-linux-gnueabi/bits/c++config.h:414,
                 from /home/user/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/../lib/gcc/arm-none-linux-gnueabi/4.7.3/../../../../arm-none-linux-gnueabi/include/c++/4.7.3/string:40,
                 from main.cpp:1:
/home/user/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/../arm-none-linux-gnueabi/libc/usr/include/gnu/stubs.h:10:29: fatal error: gnu/stubs-hard.h: No such file or directory
compilation terminated.

编译器
arm-none-linux-gnueabi-g++ -v
Using built-in specs.
COLLECT_GCC=arm-none-linux-gnueabi-g++
COLLECT_LTO_WRAPPER=/home/user/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/../libexec/gcc/arm-none-linux-gnueabi/4.7.3/lto-wrapper
Target: arm-none-linux-gnueabi
Configured with: /scratch/jbrown/2013.05-arm-linux-release/src/gcc-4.7-2013.05/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --enable-extra-sgxxlite-multilibs --with-arch=armv5te --with-gnu-as --with-gnu-ld --with-specs='%{save-temps: -fverbose-asm} %{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables} -D__CS_SOURCERYGXX_MAJ__=2013 -D__CS_SOURCERYGXX_MIN__=5 -D__CS_SOURCERYGXX_REV__=24 %{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --enable-shared --enable-lto --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery CodeBench Lite 2013.05-24' --with-bugurl=https://sourcery.mentor.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --with-build-sysroot=/scratch/jbrown/2013.05-arm-linux-release/install/arm-none-linux-gnueabi/libc --with-gmp=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-mpfr=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-mpc=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-ppl=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-cloog=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-libelf=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --disable-libgomp --disable-libitm --enable-poison-system-directories --with-build-time-tools=/scratch/jbrown/2013.05-arm-linux-release/install/arm-none-linux-gnueabi/bin --with-build-time-tools=/scratch/jbrown/2013.05-arm-linux-release/install/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.7.3 (Sourcery CodeBench Lite 2013.05-24) 

最佳答案

Sourcery CodeBench Lite 工具链不支持 armhf。学术版或个人版也没有。

您需要购买标准版或专业版才能获得。

或者,我相信 Ubuntu 的交叉编译器包支持您需要的配置(实际上,仅支持该配置)。

如果您没有使用 Ubuntu,那么 pre-built Linaro toolchains应该正是您所需要的。 (Ubuntu 交叉编译器包也是由 Linaro 人构建的,尽管使用的是 Debian/Ubuntu 特定的 deb 构建系统。)

关于floating-point - 利用 -mfloat-abi=hard 和 -mfpu=vfp/neon Codesourcery Lite 2013.05-24,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17364690/

相关文章:

C编程 float ?

c - 浮点除法 - 避免结果小于 'exact' 值的偏差

c - 没有操作系统调度程序的时间片功能

linux - 如何调整 inotify 以使用更少的内存?

c++ - Double 的乘法不如 float 的乘法精确

c - C 中 malloc() 的替代方法是什么?

c - 使用全局 C 变量的 IAR 内联汇编

c - 确保一个 cpu 在另一个 cpu 读取 "double"之前写入了 "double"?

gcc - 为 ARM-EABI 编译 Linux 内核但使用 4 字节大类型对齐?

Python:从字符串中的 float 中删除 0