Transferred from: http://blog.csdn.net/woaixiaozhe/article/details/7395435
1. Install the standard C development environment, because the Linux installation is not installed by default, so you need to install first (if you have already installed, you can eliminate this step):
#sudo apt-get Install gcc g++ libgcc1 libg++ make GDB
2. Download arm-linux-gcc-3.4.1.tar.bz2 to any directory, I downloaded it to my personal folder/home/wrq
ARM-LINUX-GCC-3.4.1.TAR.BZ2 is as follows: http://download.csdn.net/detail/woaixiaozhe/4173915
3. Unzip the ARM-LINUX-GCC-3.4.1.TAR.BZ2
#tar-JXVF arm-linux-gcc-3.4.1.tar.bz2
The decompression process takes a while, the extracted files form the usr/local/folder, enter the folder, and copy the arm folder to/usr/local/
# CD usr/local/
#cp-RV arm/usr/local/
Now the cross-compiling assembly is under/usr/local/arm/3.4.1/bin.
4. Modify the environment variables to add the path of the cross-compiler to path. (There are three methods, it is strongly recommended to use method one)
Method One: Modify the/ETC/BASH.BASHRC file
#vim/ETC/BASH.BASHRC
At the end add:
Export path= $PATH:/usr/local/arm/3.4.1/bin
Export PATH
Method Two: Modify the/etc/profile file:
# vim/etc/profile
add path settings, at the end, save the/etc/profile file as follows:
export path= $PATH:/usr/local/arm/3.4.1/bin
Method Three: #export path= $PATH:/usr/local/arm/3.4.1/bin
Note: (This is only valid under the current terminal!)
5. Immediately make the new environment variable effective without restarting the computer:
corresponding method one: #source/ROOT/.BASHRC
corresponding Method II: # source/etc/profile
6. Check to see if the path is added to path:
# echo $PATH The
displays/usr/local/arm/bin, indicating that the path to the cross-compiler has been added. At this point, the cross-compilation environment is installed.
7. Test for installation success
# arm-linux-gcc-v
The command above displays ARM-LINUX-GCC information and version
8. Compile the Hello World program, test the cross toolchain
write down the following Hello World program, saved as hello.c
#include <stdio.h>
int Main ()
{
printf ("Hello world!\n");
return 0;
}
Execute the following command:
# arm-linux-gcc-o Hello hello.c
source program error will be prompted, without any hint, it is through, you can download to the arm target board to run! You can then enter the file Hello command to see the type of the generated hello file, note that the resulting executable file can only be run under the arm system and not on its X86 pc.
Build "Go" for Linux embedded cross-compilation environment