简体   繁体   English

如何在没有编译器的Linux上安装gcc

[英]How install gcc on Linux without compiler

I have a very light Linux OS that does not have any compiler on it. 我有一个非常轻的Linux操作系统,它没有任何编译器。 How can I install gcc or g++ on it? 如何在其上安装gcc或g ++? The target hardware is an armv7-a processor. 目标硬件是armv7-a处理器。 Can I compile gcc on my x86 system and then install it on my armv7 Linux?? 我可以在我的x86系统上编译gcc然后将它安装在我的armv7 Linux上吗?

Yes, you can compile your code on your x86 device and then export it to your arm device. 是的,您可以在x86设备上编译代码,然后将其导出到您的arm设备。 But for this, you need a special compiler. 但为此,您需要一个特殊的编译器。 This process is called "cross-compilation", where you compile a code for a special target device on an other device. 此过程称为“交叉编译”,您可以在其中为其他设备上的特殊目标设备编译代码。

For arm devices, the one I used was the "arm-linux-gnueabihf-gcc" compiler. 对于arm设备,我使用的是“arm-linux-gnueabihf-gcc”编译器。

Once installed, you can use it just like your casual gcc compiler. 安装后,您可以像使用休闲gcc编译器一样使用它。 For example, on linux, it would be something like this : 例如,在linux上,它将是这样的:

$ arm-linux-gnueabihf-gcc -o your_program your_program.c

You then export the compiled output to your device, and it should work. 然后,您将编译后的输出导出到您的设备,它应该工作。

Cross-compiling may be the solution for you It allows you to compile executables for one architecture on a system of a different architecture. 交叉编译可能是您的解决方案它允许您在不同体系结构的系统上编译一个体系结构的可执行文件。 here is link http://www.landley.net/writing/docs/cross-compiling.html 这里是链接http://www.landley.net/writing/docs/cross-compiling.html

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

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