Preparation: assuming that the working directory is under the $ HOME/devel directory, the crosstool-ng under it is used to extract and compile crosstool-ng, And the cortex-a8 is used to generate the target toolchain. The generated tool chain is stored in the $ HOME/x-tools directory. In Fedora11/12, it is relatively easy to use crosstool-ng to establish a tool chain, but it is a lot of trouble to use fedora13. First, when downloading the tool curl to download files
Preparations:
Assume that the working directory is under the $ HOME/devel directory, and
Crosstool-ng is used to extract and compile crosstool-ng,
The cortex-a8 is used to generate the target toolchain.
The generated tool chain is stored in the $ HOME/x-tools directory.
In Fedora 11/12, it is relatively easy to use crosstool-ng to establish a tool chain, but it is a lot of trouble to use fedora13. First of all, when downloading the tool curl to download the file, it is always unknown that the download is complete, we recommend that you first download the components required by crosstool-ng and put them in the target/tarbils directory of the target directory before compiling.
1. download the latest generation tool from the official crosstool-ng website. The latest version is 1.7.1.
Http://ymorin.is-a-geek.org/projects/crosstool
Decompress the package to the specified directory.
$ Cd $ HOME/devel
$ Tar-jvxf crosstool-ng-1.7.1.tar.bz2
$ Crosstool-ng-1.7.1 cd
$./Configure-local
$ Make
Create a directory cortex-a8 to generate the target system.
$ Cd $ HOME/devel
$ Mkdir cortex-a8
$ Cortex-a8 cd
$ Cp ../crosstool-ng-1.7.1/samples/arm-cortex_a8-linux-gnueabi/crosstool. config. config
$ ../Crosstool-ng-1.7.1/ct-ng menuconfig
Select "C-library/extra target CFLAGS" and enter-U_FORTIFY_SOURCE.
Note: If you do not define this macro, you can use the tool chain compilation function. www.linuxidc.com can also use the tool chain to compile u-boot and Linux kernel, but the printf in glibc is faulty, as a result, the application that uses the printf series functions produces a segment error, that is, busybox is abnormal and cannot even access the command line.
Remove the Native GDB option at the same time. Native GDB is a Native GDB running on the target board, that is, debugging programs directly on the target board, but it is not available now. Remove this option to avoid compilation errors.
Start Compilation
$ ../Crosstool-ng-1.7.1/ct-ng build.2
Build.2 indicates that two parallel compilation tasks run simultaneously. Generally, several tasks are determined based on the number of CPU cores.
The following error occurs when compiling to ClooG/ppl:
[ALL]/usr/bin/ld:/home/xhs/devel/crosstool-ng/cortex-a8/targets/arm-cortex_a8-linux-gnueabi/build/static/lib/libppl. a (MIP_Problem.o): undefined reference to symbol 'sqrt @ GLIBC_2.0'
[ALL]/usr/bin/ld: note: 'sqrt @ GLIBC_2.0 'is defined in DSO/lib/libm. so.6 so try adding it to the linker command line
[ALL]/lib/libm. so.6: cocould not read symbols: Invalid operation
[ALL] collect2: ld returned 1 exit status
This problem does not occur during Fedora12. It is obvious that the error message is due to the lack of the sqrt symbol during the link. It is known that this function is in the math library, therefore, you must specify the-lm parameter during the link. You can solve this problem in two ways,
1. Modify Makefile. am Of The cloog-ppl project to add AM_LDFLAGS =-lm, and regenerate the project file through autoreconf. It is troublesome.
2, the simpler way is to modify the crosstool-ng compilation script, find the crosstool-ng-1.7.1/scripts/build/companion_libs/cloog. sh locate the row cloog_LDFLAGS = '-lstdc ++' and change it to cloog_LDFLAGS = '-lstdc ++-lm'
Recompile, cloog-ppl compiled through, but encountered the same problem when compiling gcc-core and gcc-final, find crosstool-ng-1.7.1/scripts/build/cc/gcc. sh, find core_LDFLAGS = '-lstdc ++' and final_LDFLAGS = '-lstdc ++', and add the-lm parameter.
Recompile and pass. If the generated toolchain does not change the path, it should be stored in the $ HOME/x-tools directory and packaged into a compressed file to back up the labor results
$ Cd
$ Tar-jvcf arm-cortex_a8-gcc.tar.bz2 x-tools/
Attached crosstool-ng-1.7.1 patch:
- Diff-uNr crosstool-ng-1.7.1/scripts/build/cc/gcc. sh crosstool-ng-1.7.1.modified/scripts/build/cc/gcc. sh
- --- Crosstool-ng-1.7.1/scripts/build/cc/gcc. sh 2010-06-28 00:38:14. 000000000 + 0800
- ++ Crosstool-ng-1.7.1.modified/scripts/build/cc/gcc. sh 2010-07-13 00:07:32. 299329759 + 0800
- @-155, 7 + 155, 7 @@
- # The libstdc ++ is not pulled automatically, although it
- # Is needed. Shoe-horn it in our LDFLAGS
- If["$ {CT_COMPLIBS_SHARED }"! ="Y"]; Then
- -Core_LDFLAGS ='-Lstdc ++'
- + Core_LDFLAGS ='-Lstdc ++-lm'
- Fi
- If["$ {CT_CC_GCC_USE_GMP_MPFR }"="Y"]; Then
- Extra_config + = ("-- With-gmp =$ {CT_COMPLIBS_DIR }")
- @-330,7 + 330,7 @@
- # The libstdc ++ is not pulled automatically, although it
- # Is needed. Shoe-horn it in our LDFLAGS
- If["$ {CT_COMPLIBS_SHARED }"! ="Y"]; Then
- -Final_LDFLAGS ='-Lstdc ++'
- + Final_LDFLAGS ='-Lstdc ++-lm'
- Fi
- If["$ {CT_CC_GCC_USE_GMP_MPFR }"="Y"]; Then
- Extra_config + = ("-- With-gmp =$ {CT_COMPLIBS_DIR }")
- Diff-uNr crosstool-ng-1.7.1/scripts/build/companion_libs/cloog. sh crosstool-ng-1.7.1.modified/scripts/build/companion_libs/cloog. sh
- --- Crosstool-ng-1.7.1/scripts/build/companion_libs/cloog. sh 2010-06-28 00:38:14. 000000000 + 0800
- ++ Crosstool-ng-1.7.1.modified/scripts/build/companion_libs/cloog. sh 2010-07-12 23:41:20. 722454427 + 0800
- -56,7 + 56,7 @@
- Cloog_opts + = (-- enable-shared -- disable-Static)
- Else
- Cloog_opts + = (-- disable-shared -- enable-Static)
- -Cloog_LDFLAGS ='-Lstdc ++'
- + Cloog_LDFLAGS ='-Lstdc ++-lm'
- Fi
- CFLAGS ="$ {CT_CFLAGS_FOR_HOST }"