Linux installation ARM-LINUX-GCC

  

1. Install the standard C development environment, because the Linux installation is not installed by default, so you need to install it first (if it is already installed, you can avoid 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 The download address of /home/wrq arm-linux-gcc-3.4.1.tar.bz2 is as follows:

3. Unzip 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 unzipped file forms the usr/local/folder, enters the folder, and copies the arm folder to /usr/local/# cd usr /local/#cp -rv arm /usr/local/Now the cross-compiled assembly is under /usr/local/arm/3.4.1/bin

4. Modify the environment variable and put the cross compiler The path is added to the PATH. (There are three methods, it is strongly recommended to use method one) Method 1: 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 2: Modify the /etc/profile file: # vim /etc/profile Increase the path setting, add the following at the end, save the /etc/profile file: export PATH=$PATH:/usr/local/arm/3.4.1/bin Method 3: #export PATH=$PATH:/usr/local/arm/3.4.1/bin Note: (This can only be valid under the current terminal!)

5. Immediately make the new environment variable take effect without restarting the computer: Corresponding method one: #source /root/.bashrc Corresponding method two: #源 /etc/profile

6. Check if the path is added to the PATH : # echo $PATH shows /usr/local/arm/bin in the content, indicating that the path of the cross compiler has been added to the PATH. At this point, the cross-compiler environment is installed. (This article address:) 7. Test whether the installation is successful # arm-linux-gcc -v The above command will display the arm-linux-gcc information and version, this is the information I displayed: Reading specs from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/specs Configured with: /work/crosstool-0.27/build/arm-linux/gcc-3.4.1-glibc-2.3.2/gcc- 3.4.1 /configure --target=arm-linux --host=i686-host_pc-linux-gnu

--prefix=/usr/local/arm/3.4.1 --with-headers=/usr/local /arm/3.4.1/arm

-linux/include --with-local-prefix=/usr/local/arm/3.4.1/arm-linux --disable

- Nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable- languages=c,c++ --enable-shared --enable-c99 --enable-long-long Thread model: posix Gcc version 3.4.1

8. Compile the Hello World program and test the cross toolchain. Write the following Hello World program and save it as hello.c #include <stdio.h> int main() { printf( "Hello World!\ "); return 0; } execute the following command : # arm-linux-gcc -o hello hello.c

Copyright © Windows knowledge All Rights Reserved