1. Install the standard C development environment, because Ubuntu installation is not installed by default, so you need to install it first:
sudo apt-get install gcc g++ libgcc1 libg++ make GDB
2. Download the latest version of the cross compiler from ftp://ftp.arm.linux.org.uk/pub/armlinux/toolchain/, I downloaded the cross-3.2.tar.bz2, extracted to the Downloan directory, will generate home /downloads/usr/local/arm/, and then sudo cp-r arm/usr/local/arm/
3. Add the path to the cross-compiler
sudo vi/etc/bash.bashrc
Add the following code later:
if [-d/usr/local/arm]; Then
Path=/usr/local/arm/bin: "${path}"
Fi
4. Make the new environment variable effective
# Source/etc/profile
5. Check to see if the path is joined to path:
Echo $PATH
If there is/usr/local/arm/bin in the displayed content, the path of the cross-compiler has been added
Since then, the cross-compilation environment has been installed.
6. Test Example:
Code HELLO.C
#include <stdio.h>int main () {printf ("Ubuntu, I Am linux-arm-toolchain\n");}
The terminal enters the directory where the HELLO.C is located and executes:
ARM-LINUX-GCC Hello.c-o Hello
Compilation succeeded.
The problem encountered:
Copy a relatively simple code from the Web, compile with the following issues:
Test_getopt.c:9:35:error:stray ' \342 ' in program
Test_getopt.c:9:35:error:stray ' \200 ' in program
Test_getopt.c:9:35:error:stray ' \235 ' in program
Test_getopt.c:12:3: Error:stray ' \342 ' in program
Test_getopt.c:12:3: Error:stray ' \200 ' in program
Test_getopt.c:12:3: Error:stray ' \230 ' in program
Test_getopt.c:12:3: Error:stray ' \342 ' in program
Test_getopt.c:12:3: Error:stray ' \200 ' in program
Test_getopt.c:12:3: Error:stray ' \231 ' in program
Test_getopt.c:13:4: Error:stray ' \342 ' in program
Test_getopt.c:13:4: Error:stray ' \200 ' in program
Say, this problem occurs because the source code in the presence of Chinese characters, such as ",", and so on, it can be changed!