The production __linux of ARM Linux UCLIBC Cross-compilation tool chain

Source: Internet
Author: User

Original address: http://blog.csdn.net/chehlcy/article/details/5456118 (I have been modified, and the possible problems to give a solution)

Making a cross-compilation tool chain is a hassle, because cross-compilation ntfsprogs have to do it all over again, now summarize the process here for future reference.

Material: Binutils,gcc,linux KERNEL,UCLIBC

The version I used is:

binutils-2.16

gcc-3.4.3

linux-2.6.14

uClibc-0.9.28

Basic process:

1. Compile Binutils

2. Compiling GCC without library

3. Configure and compile Linux Kenerl

4. Compile uclibc

5. Recompile gcc to get the complete tool chain.

Detailed steps:

Note: The following scripts are manually entered again, not copy from the original system, there may be input errors

1.binutils of compilation

There is no suspense, the compilation script is as follows:

#。 /bin/sh

./configure--target=arm-linux--prefix=/opt/tools--program-prefix=arm-linux-

Make

Make install

Can be generated under the/opt/tools Arm-linux-ar Arm-linux-ld and other necessary tools

2. Compiling GCC without library

This step must be carefully configured, because the build gcc some of the functional modules need to support the C library, only the dependent modules to block the step can be successfully compiled, the step compiled script as follows:

See also: http://blog.csdn.net/dragon101788/article/details/17559215 section Fourth

#。 /bin/sh

./configure--target=arm-linux/

--prefix=/opt/tools/

--program-prefix=arm-linux-/

--disable-shared/

--disable-threads/

--enable-languages= "C"/

--with-newlib

Make

Make install

Some books said to modify T-linux file, I test as long as add--with-newlib can be avoided.

3. Configure and compile Linux kernel

See also: http://blog.csdn.net/dragon101788/article/details/17559215 section Fifth

This step is to get the C library in the system header file, in the compilation of UCLIBC will specify the location of kernel SRC, this step, although just configure the kernel and will include/asm link to Asm-arm can, but in order to test the 2nd step compiled GCC, may wish to complete the compilation of the kernel. The configuration depends on the kernel you are using, and this step does not need to be verbose.


4. Configure compilation UCLIBC

In this step you need to specify the location of kernel SRC, personal attempts must be specified as an absolute path, the relative path to compile the process will be wrong, the configuration process to be based on the system needs of the UCLIBC configuration, and sometimes some of the modules will not be compiled, then need to do the appropriate configuration adjustment. When this step is complete, you can generate the header and library files required for the full tool chain.

Menuconfig settings:

Arget architecture (ARM)--->

Target architecture Features and Options--->

Target ABI (Eabi)--->
Target Processor Type (Generic Arm)--->
Using ELF File Format * * *
Target Processor Endianness (Little endian)--->
[*] Target CPU has a memory management unit (MMU)
[*] Do your want to utilize the MMU?
[*] Enable floating point number support
[*] Target CPU has a floating point unit (FPU)
[] Enable full C99 Math library support
[] Enable C99 floating-point environment
(${prefix}/${target}/include) Linux Kernel Header Location

Library Installation Options--->

($ (runtime_prefix) Lib) Shared Library Loader Path

(/${TARGET}/UCLIBC) UCLIBC Runtime Library Directory: Note: This should be completed, each compile will be from the designated directory to find ulibc.so, if not filled out, from the default load path, recommended empty

(/UCLIBC-DEV) UCLIBC Development Environment Directory: NOTE: This should be filled in, each compile will be from the designated directory to find ulibc.so, if not filled out, from the default loading path, recommended empty

Modify the cross compilation path in. config or modify the environment variable cross=

cross_compiler_prefix= "arm-linux-gnueabi-"

Use commands when installing

Make Prefix=${pwd}/hu/install

Copy all files in Hu directory to ${prefix}/${target} directory after compilation completes installation

Note: If the menu is filled with a catalog, it will appear in the configuration directory when it is installed


Problems that may be encountered in compiling:

Question 1:

Libc/sysdeps/linux/mips/crt1. S:assembler messages:
Libc/sysdeps/linux/mips/crt1. S:117:warning:no. Cprestore pseudo-op used in PIC code
As LIB/CRTI.O
As LIB/CRTN.O
/tmp/cc5bchrl.s:assembler messages:
/tmp/cc5bchrl.s:error:. Size expression for _init does not evaluate to a constant
/tmp/cc5bchrl.s:error:. Size expression for _fini does not evaluate to a constant
Make: * * * [LIB/CRTN.O] Error 1

Workaround:

Got the thing resolved as said in the patch by removing the lines
. Size _init,.-_init
. Size _fini,.-_fini
From Uclibc-0.9.31/libc/sysdeps/linux/arm/crtn. S

In Uclibc-0.9.31/libc/sysdeps/linux/arm/crtn. s file, @ Note these two lines


Question 2:

Error: 651:note:previous declaration of ' Getline ' is here

error:conflicting types for ' getline '
651:note:previous declaration of ' Getline ' is here

pattern.c:in function ' getline ':

Workaround: Getline and system-defined getline () function conflicts. It would be nice to change the name.

5. Recompile gcc

This step is to open the first time to compile GCC on the basis of already owning C library, including dynamic link support, thread support, and C library integration.

The compilation script is as follows:

#。 /bin/sh

./configure--target=arm-linux/

--prefix=/opt/tools/

--program-prefix=arm-linux-/

--enable-languages= "C"/

--with-headers=.. /uclibc-0.9.28/build/include/#注: There is a problem with compiling here

--with-libs=.. /uclibc-0.9.28/build/lib/#注: There is a problem with compiling here

--with-sysroot= ' ${exec_prefix}/xxx ' #将xxx替换成prefix的路径, refer to http://blog.csdn.net/dragon101788/article/details/ 17509987sysroot and Specs

Make

Make install


Problems may occur:

/home/dragon/usr/arm/dragon-4.8.2/arm-uclibc-linux-gnueabi/bin/ld:cannot find/lib/libc.so.0
/home/dragon/usr/arm/dragon-4.8.2/arm-uclibc-linux-gnueabi/bin/ld:cannot FIND/LIB/UCLIBC_NONSHARED.A
/home/dragon/usr/arm/dragon-4.8.2/arm-uclibc-linux-gnueabi/bin/ld:cannot find/lib/ld-uclibc.so.0
Collect2:error:ld returned 1 exit status

This has been studied in the UCLIBC link to the wrong root directory/lib/libc.so.0

Actually, it's $prefix/$TARGET/lib/. Libc.so Point, libc.so is actually a text file point to the location of the compile-time link, when the compiler moved the same problem when the location, later can modify the file to move the directory, ULIBC compiler directory to move when you specify an absolute path

Where--with-headers specifies the header file of the generated uclibc that is compiled,--with-libs specifies the UCLIBC library file, in this case only the compilation of C programs is supported.

Not surprisingly, a arm-linux cross compilation tool chain is completed, and on the basis of the smooth passage of the process, other parameters can be configured to achieve optimal performance. However, it is almost impossible to successfully compile the tool chain for the first time.

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.