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.
The steps are coming
- 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.
- 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. - 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 commandsource ~/.bashrc
to make it take effect immediately , or restart your system. - Verify whether the cross-compilation tool chain is installed successfully and use the command
arm-linux-gnueabihf-gcc -v
to 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.c
the command to compile and generate a C language executable file