Ubuntu cross compilation environment arm-linux-gcc build

    First, let's briefly introduce the so-called building cross-compilation environment, that is, installing and configuring the cross-compilation tool chain. Under this environment, compile the operating system and application programs required by the embedded Linux system, and then upload it to the target machine.
    The cross-compilation tool chain is for compiling, linking, processing and debugging program code of cross-platform architecture. For the cross-developed tool chain, a prefix is ​​added to the file name to distinguish the local tool chain. For example, arm-linux-represents a cross-compilation tool chain for arm; arm-linux-gcc represents a compiler that uses gcc. Except for the architecture-related compilation options, the method of use is the same as gcc on the Linux host, so Linux programming techniques are also applicable to embedded. However, not all versions can be used, and various software packages often have version matching problems. For example, the arm-linux-gcc-4.3.3 version of the cross-compilation tool chain is required to compile the kernel, and the arm-linux-gcc-3.4.1 cross-compiling tool chain will cause the compilation to fail.
     So what is the difference between gcc and arm-linux-gcc? The difference is that gcc is a C language compiler under Linux, and the compiled program is executed locally, while arm-linux-gcc is used to cross-platform C language compiler under Linux, and the compiled program is on the target machine (such as the ARM platform ), Embedded development should use the embedded cross-compilation tool chain.

1. Store the compressed package arm-linux-gcc-4.4.3.tar.gz in a directory, this directory is the directory you will decompress, and this directory cannot be deleted in the future. / home / song / software, as shown in the figure below, remember this path, you will use it later.

2. Use the tar command: tar zxvf arm-gcc-4.4.3.tar.gz to decompress and store arm-linux-gcc-4.4.3.tar.gz in the / usr / local / bin / folder

3. Next, configure the system environment variables and add the path of the cross-compilation tool chain to the environment variable PATH so that you can use these tools in any directory. Write down the installation path in the previous step, use the command: vim / etc / profile to edit the profile file, and add environment variables.
Add in the last line of the profile: export PATH = $ PATH / usr / local / bin / 4.4.3 / bin This path is the path where the bin directory is located, maybe yours is different, fill it according to your actual directory.


4. Use the command: source / etc / profile to make the environment variables take effect


5. Enter the command arm-linux on the terminal and then press the Tab key. If a prompt message appears, the environment variable is set successfully.

6. Use the command: arm-linux-gcc -v The following error message will appear: /home/song/software/opt/FriendlyARM/toolschain/4.4.3/bin/arm-linux-gcc: 15: exec: / home /song/software/opt/FriendlyARM/toolschain/4.4.3/bin/.arm-none-linux-gnueabi-gcc: not found
that the reason for this problem is that Ubuntu 12.04 uses 64-bit, The solution is to use the command: sudo apt-get install ia32-libs to install some 32-bit libraries. If the installation is unsuccessful, it is because the Ubuntu 16.04 version does not support the ia32-libs software package, but uses the lib32ncurses5, lib32z1 software The package is used as an alternative, so it should be installed and executed in the Ubuntu 16.04 version:

  1. sudo apt-get install lib32ncurses5 lib32z1

7. After installing the 32-bit library, use the command: arm-linux-gcc -v, this time you can see the relevant information.
 

Reprinted from: https://www.cnblogs.com/panda88/p/7686866.html

Published 2 original articles · won 4 · views 3217

Guess you like

Origin blog.csdn.net/qq_27630885/article/details/85228607