The production of the ARM cross-compilation chain-general Linux technology-Linux programming and kernel information. The following is a detailed description. Here, we don't need to talk about what is cross-compilation. Here we provide two ways to make it.
1. Download the compiled file directly. For example: http://arm.linux.org.uk, here provides compiled cross, such as cross-3.3.2.tar.bz2, cross-3.0.tar.bz2. Download a package, decompress it, and create a proper link or output environment variables.
This operation is very simple, but it cannot be defined according to your own needs. You can only select the compiled items.
2. Use crosstool to create one.
A. Download the source code package from the official CROSSTOOL website, decompress the package, and enter the decompressed directory.
$ Sudo wget http://kegel.com/crosstool/crosstool-0.42.tar.gz
$ Sudo tar-xzvf crosstool-0.42.tar.gz
$ Crosstool-0.42 cd
B. Create a directory as ROOT to store the generated cross-compilation chain
Change the directory owner to a normal user.
For example, the Directory of the generated cross-compilation chain is/opt/crosstool, as shown below:
C. Modify the script file for the target board.
$ Sudo vi demo-arm.sh
(1) The environment variables can be modified according to the actual situation.
TARBALLS_DIR = $ HOME/downloads
RESULT_TOP =/opt/crosstool
Export TARBALLS_DIR RESULT_TOP
Gcc_ages = "c, c ++"
Export gcc_ages
(2) Select a combination of the Cross-compilation chains to be created in several lines of eval statements, and remove the # Number of the eval of the row. For example, to use a tool chain with gcc 3.3.3 and glibc 2.3.2
Eval 'cat arm. dat gcc-3.4.5-glibc-2.3.6.dat 'sh all. sh -- notest
D. Modify the schema configuration file for the eval row in the target board script file demo-arm.sh
$ Sudo vi arm. dat
You can change the TARGET variable
TARGET = arm-S3C2410-linux-gnu (your arm Model)
E. Modify the matching file for the toolchain that appears in the eval row in the target board script file demo-arm.sh
$ Sudo vi gcc-3.4.5-glibc-2.3.6.dat
The preceding variables must be modified according to the actual situation. For example, if you want to download linux2.6 and the latest version of gdb. For specific kernel versions, see http://kernel.org/and ftp://ftp.gnu.org/pub/gnu/gdb. For example.
LINUX_DIR = linux-2.6.12.1
GDB_DIR = gdb-6.0
F. Run the script as a normal user
$ Sudo sh demo-arm.sh
Entering the long waiting process ......
3. Configure and test the path after installation.
Edit ~ /. Bash_profile, add such a line before the export PATH in it, PATH =/opt/crosstool/gcc-3.4.5-glibc-2.3.6/arm-S3C2410-linux-gnu/bin: $ PATH, after which my is like this
Then we can. You can start testing. The test method is very simple. Just find a program source code and compile it. The compilers used here generate binary files, and the executable files generated by gcc in peacetime are different. For example, the file I tested was test. c,
# Include
Int main ()
{
Printf ("Hello! ");
Return 0;
}
Call the new arm-linux-gcc to compile: arm-S3C2410-linux-gnu-gcc-o test. c. The generated test file is a binary executable file, which is not commonly used. Therefore, it cannot be executed on a PC. The system will prompt: bash :. /test: cannot execute binary file. Therefore, you cannot use this method to test whether cross-compilation is successful. Instead, use the file command. For example, my file is as follows:
File test
The result is as follows:
Test: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), for GNU/Linux 2.4.3, not stripped
If such a result is displayed, the cross-compilation environment has been installed successfully. Otherwise, try again.
Note: In the second method, there are two download methods for gcc, gdb, and other files. One is to set the network and let the shell program download it by itself. This method is simple, however, the download speed is not flattering. The other is to use the download tool to download, and then tell the storage path to the demo-arm.sh, that is, the content in 2. C. The speed of this method is satisfactory. Recommended.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service