Table of contents
1. Cross-compilation notes
1.1. Cross-compilation ./configure --build,--host,--target
Settings
-
build: The host that performs code compilation, normally it is your host system. This parameter is generally guessed by
config.guess
. Of course you can also specify it yourself. -
host: The host where the compiled binary program is executed. Because most of them are compiled and executed locally, this value is equal to build. Only when cross-compiling (that is, compiling on the local machine and executing on other system machines) will the build and host be different. Use host to specify the running host.
-
target: This option is only used when establishing a cross-compilation environment, and will not be used in normal compilation or cross-compilation. He uses the compiler on the build host to compile a new compiler (binutils, gcc, gdb, etc.). Other programs compiled by this new compiler will run on the system specified by target.
1.1.1. Let us take compiling binutils as an example:
Configuration one:
./configure --build=mipsel-linux --host=mipsel-linux --target=mipsel-linux
Note: We use the mipsel-linux compiler to compile binutils. The compiled binutils runs on mipsel-linux. This binutils is used to compile code that can run on mipsel-linux.
Effect: Of course no one will use this option to compile binutils
Configuration two:
./configure --build=i386-linux --host=mipsel-linux --target=mipsel-linux
Description: Use the i386-linux compiler to compile binutils. The compiled binutils runs on mipsel-linux. This binutils is used to compile code that can run on mipsel-linux.
Purpose: This option can be used to compile its compiler for other machines.
Configuration three:
./configure --build=i386-linux --host=i386-linux --target=mipsel-linux
Note: We use the i386-linux compiler to compile binutils. The compiled binutils runs on i386-linux. This binutils is used to compile code that can run on mipsel-linux.
Function: This option is used to establish a mipsel-linux cross-compilation environment on the i386 host.
Configuration four:
./configure --build=mipsel-linux --host=i386-linux--target=mipsel-linux
Note: We use the mipsel-linux compiler to compile binutils. The compiled binutils runs on i386-linux. This binutils is used to compile code that can run on mipsel-linux.
Function: This option can be used to create a mipsel-linux cross-compilation environment on the i386 host. However, the cross-compilation environment is compiled on mipsel-linux and installed on the i386-linux host. It is estimated that Not many people would use it this way.
In general, compilation is cross-compilation only when host != build
. Otherwise, it compiles normally.
1.1.2. Other information records
Operation 1: Use gcc -v
to view configuration information
mayue6@Cpl-Ezviz-General-14-173:~/nfs/gdb$ gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
目标: x86_64-linux-gnu
配置为: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
线程模型: posix
gcc 版本 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
Operation 2: Cross-compilation steps for open source software
./configure –help 查看帮助文档
./configure –prefix=安装路径 --build=i686-linux-gnu --host=arm-poky-linux-gnueabi
make && make install
Operation 3: Must be performed when re-cross-compiling
make clean -w
make distclean