First, download the toolchain and unzip it to the root directory.
(1) Copy the downloaded toolchain (I use toolchains_for_s3c2410.tar.bz2) to the/home directory via Samba
Decompression toolchains_for_s3c2410.tar.bz2:
TAR–JXVF toolchains_for_s3c2410.tar.bz2
The Crosstool directory is generated and is typically copied to the root directory.
caoyi@ubuntu:/home$ ls
Caoyi Crosstool Kernel Study toolchains_for_s3c2410.tar.bz2
caoyi@ubuntu:/home$ sudo mv crosstool//
(2), get the absolute path of the crossover tool
CD crosstool/gcc-3.4.5-glibc-2.3.6/arm-linux-gnu/bin/
PWD command gets the absolute path where the cross-tool chain executable file is stored
/crosstool/gcc-3.4.5-glibc-2.3.6/arm-linux-gnu/bin
(3), modify the value of the environment variable path
caoyi@ubuntu:/home$ CD ~ (current user directory, my:/home/caoyi)
caoyi@ubuntu:/home$ vim. BASHRC
In the last line, add:
Export path= $PATH:/crosstool/gcc-3.4.5-glibc-2.3.6/arm-linux-gnu/bin
Save exit
or modify/etc/profile
Execute command: Vim/etc/profile
Add to:
Export path= $PATH:/opt/crosstool/gcc-3.4.5-glibc-2.3.6/arm-linux-gnu/bin
Save exit
Last executed: Source/etc/profile
Ok
Execute command: Source ~/.BASHRC
Second, compile C code using the Cross tool chain
(1), create a new folder in/opt/filesystem, specifically to store the cross-compiled executable code
caoyi@ubuntu:/home$ Cd/rootfs/filesystem
caoyi@ubuntu:/rootfs/filesystem/$ sudo mkdir work
caoyi@ubuntu:/rootfs/filesystem/$ sudo chmod 777-r work (note to change the properties, otherwise the compiler will have permission issues)
caoyi@ubuntu:/home$ cd/rootfs/filesystem/work/
caoyi@ubuntu:/rootfs/filesystem/work$ sudo vim hello.c
caoyi@ubuntu:/rootfs/filesystem/work$ sudo arm-linux-gnu-gcc hello.c–o Hello
caoyi@ubuntu:/rootfs/filesystem/work$ ls
Hello hello.c
(2), in the terminal of the Development Board, namely Putty (serial port), enter the/work/directory to run Hello
# CD Work
# ls
Hello hello.c
#./hello
Hello world!
#