简体   繁体   English

在ARM下是否有gcc编译器?

[英]Is there a gcc compiler under ARM?

我知道,如果我想为ARM设备编译程序,则需要一个特殊版本的gcc,该版本在x86下运行并针对ARM进行编译(交叉编译),是否可以在ARM下针对ARM进行编译?

If you are happy to compile from source, any recent version of GCC can be built natively on an ARM device, targeting that ARM device. 如果您愿意从源代码进行编译,则可以在ARM设备上以该ARM设备为目标本机构建任何最新版本的GCC。 The dependencies to compile GCC and the size of the code base might give you some difficulties, but I regularly build the up-to-date GCC development branch on my Raspberry Pi 2. 编译GCC的依赖关系和代码库的大小可能会给您带来一些困难,但是我经常在Raspberry Pi 2上构建最新的GCC开发分支。

Follow the instructions at: https://gcc.gnu.org/install/ to get the prerequisites you need, and when configuring the compiler use something like: 按照https://gcc.gnu.org/install/上的说明获取所需的先决条件,并且在配置编译器时使用类似以下内容的东西:

  --with-cpu=cortex-a15 --with-float=hard --with-fpu=neon --with-mode=thumb

Modifying the --with-cpu and --with-fpu options as required for your system. 根据系统要求修改--with-cpu--with-fpu选项。

If you are looking for prebuilt binaries, most distributions (and certainly Debian and Ubuntu) which run on ARM will provide you with a package you can install, just like your x86 systems. 如果您正在寻找预构建的二进制文件,那么大多数运行在ARM上的发行版(当然还有Debian和Ubuntu)将为您提供可以安装的软件包,就像x86系统一样。

Consider downloading the source code for the compiler of your choice. 考虑为您选择的编译器下载源代码。 Here is a location that contains the source you could attempt to use. 是一个包含您可以尝试使用的源的位置。

I could see one using, on an x86 box to start, an x86 cross compiler to compile the ARM version of the compiler for your local ARM based system. 我可以看到有人在x86盒子上使用一个x86交叉编译器来为基于ARM的本地系统编译ARM版本的编译器。 Then you can use the native version going forward on your system. 然后,您可以使用系统上的本机版本。

yes there are cross compilers and yes there are native compilers. 是的,有交叉编译器,是的,有本地编译器。 You can for example buy a raspberry pi and install one of the canned distros and that gives you a native compiler, or you can for example use qemu and run an arm distro built for one of the many systems supported by qemu simulations (and run a native compiler on that)...or just cross compile. 例如,您可以购买树莓派并安装一个罐装发行版,从而为您提供本机编译器,或者您可以使用qemu并运行为qemu模拟支持的众多系统之一而构建的arm发行版(并运行本机编译器)...或只是交叉编译。

Recent Debian for Raspberry Pi 2 came with gcc 4.6. 最近的Raspberry Pi 2 Debian附带了gcc 4.6。 For more advanced features, such as for NEON, you can install gcc 4.8, or later. 对于更高级的功能,例如NEON,可以安装gcc 4.8或更高版本。 Example compile commands for different FPU options are: 不同FPU选项的示例编译命令如下:

 gcc 4.6
 gcc  linpack.c cpuidc.c -lm -lrt -O3 -march=armv6 -mfloat-abi=hard -mfpu=vfp -o linpackPiA6
 gcc 4.8
  gcc  linpack.c cpuidc.c -lm -lrt -O3 -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=neon-vfpv4 -o linpackPiA7 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM