[Cross-compilation environment] Tutorial on installing arm-linux cross-compilation environment to a virtual machine (concise version)

I just saw that many tutorials were a bit cumbersome, so I wrote one
The cross-compilation environment I decompressed and installed is a version of Linaro GCC, which can be used to compile the target code of arm-linux-gnueabihf on the x86_64 host.

Insert image description here

The steps are coming

  1. Create a directory in your Ubuntu system , such as /usr/local/arm, and then copy the downloaded gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf.tar.xz to the directory.
  2. Unzip the cross-compilation tool in this directory and use the command sudo tar -vxf gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf.tar.xz. After decompression is completed, a folder named gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf will be generated. This folder contains your cross-compilation tool chain.
  3. Set environment variables to enable the cross-compilation tool chain to take effect. Just edit your ~/.bashrc file, use the command to add the environment variable export PATH=$PATH:/usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin, and then use the command source ~/.bashrcto make it take effect immediately , or restart your system.
  4. Verify whether the cross-compilation tool chain is installed successfully and use the command arm-linux-gnueabihf-gcc -vto view the version information. If 4.9.4 is displayed, the installation is successful.

Compile (such as C file) : Use arm-linux-gnueabihf-gcc -o test test.cthe command to compile and generate a C language executable file

Guess you like

Origin blog.csdn.net/weixin_62676865/article/details/135196018