GNU configure中的build/target和host的区别

----------------------------------------------------------------------------------------------------------

如何交叉编译一个源码包

1. 将交叉编译工具链bin目录添加到PATH

2. ./configure 。 设置 --host=ppc-linux ( host 对应目标板架构及操作系统类型 )

可能会遇到 需要 修改 config.sub 的情况。对照arm 及 交叉编译工具链的 gcc 前面的部分来添加即可。

如: 交叉编译工具链叫做 ppc-linux-gcc 那么 就应该添加 ppc-linux . 即交叉编译链的 -gcc 前面的那部分

 321     | ppc-* | ppc-linux-* \

 

 691     ppc*)
 692         basic_machine=ppc-pc
 693         os=-linux
 694         ;;

 

其他的如 enable-xxx-xxx 根据实际情况 来进行配置。

3. make

4. make install

 

------------------------------------------------------------------------------------------------------

 

参考资料:

  1. http://en.wikipedia.org/wiki/Cross_compile
  2. http://www.airs.com/ian/configure/configure_5.html#SEC30
  3. http://oss.lzu.edu.cn/blog/blog.php?/do_showone/tid_116.html
  1. build 就是你现在使用的机器。
  2. host 就是你编译好的程序能够运行的平台。
  3. target 编译程序能够处理的平台。一般都用在构建编译本身的时候(gcc), 才用target, 也就是说平时我们所说的交叉编译用不到target.

    The GNU autotools packages (i.e. autoconf, automake, and libtool) use the notion of a build platform, a host platform, and a target platform.
    The build platform is where the code is actually compiled.
    The host platform is where the compiled code will execute.
    The target platform usually only applies to compilers. It represents what type of object code the package itself will produce (such as cross-compiling a cross-compiler); otherwise the target platform setting is irrelevant. For example, consider cross-compiling a video game that will run on a Dreamcast. The machine where the game is compiled is the build platform while the Dreamcast is the host platform.
   

    When building cross compilation tools, there are two different systems involved: the system on which the tools will run, and the system for which the tools generate code.
    The system on which the tools will run is called the host system.
    The system for which the tools generate code is called the target system.
    For example, suppose you have a compiler which runs on a GNU/Linux system and generates ELF programs for a MIPS embedded system. In this case the GNU/Linux system is the host, and the MIPS ELF system is the target. Such a compiler could be called a GNU/Linux cross MIPS ELF compiler, or, equivalently, a ‘i386-linux-gnu’ cross ‘mips-elf’ compiler.

Target usually have a meaning for developemt tool only.
    比如: 在386的平台上编译可以运行在arm板的程序 ./configure –build=i386-linux,–host=arm-linux就可以了.
    因为一般我们都是编译程序而不是编译工具.
    如果我们编译工具,比如gcc,这个target就有用了.如果我们需要在一个我们的机器上为arm开发板编译一个可以处理 mips程序的gcc,那么target就是mips了.

Example:
    1. ./configure --build=mipsel-linux --host=mipsel-linux
--target=mipsel-linux' will build native mipsel-linux binutils on
mipsel-linux.
    2. ./configure --build=i386-linux --host=mipsel-linux
--target=mipsel-linux' will cross-build native mipsel-linux binutils on
i386-linux.
    3. ./configure --build=i386-linux --host=i386-linux
--target=mipsel-linux' will build mipsel-linux cross-binutils on
i386-linux.
    4. ./configure --build=mipsel-linux --host=i386-linux
--target=mipsel-linux' will cross-build mipsel-linux cross-binutils for
i386-linux on mipsel-linux.

    As you see, only if $build != $host a cross-compilation is performed.

 

转自:http://hi.baidu.com/mylover433/item/58f9742c8e4b5d10087508b3

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
mkdir -p build && cd build && cmake .. -- The C compiler identification is GNU 9.3.0 -- The CXX compiler identification is unknown -- Check for working C compiler: /work/bsp/rk356x/buildroot/output/rockchip_rk3568/host/bin/aarch64-buildroot-linux-gnu-gcc -- Check for working C compiler: /work/bsp/rk356x/buildroot/output/rockchip_rk3568/host/bin/aarch64-buildroot-linux-gnu-gcc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done CMake Error in CMakeLists.txt: No CMAKE_CXX_COMPILER could be found. Tell CMake where to find the compiler by setting either the environment variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH. CMake Warning (dev) in CMakeLists.txt: No cmake_minimum_required command is present. A line of code such as cmake_minimum_required(VERSION 3.10) should be added at the top of the file. The version specified may be lower if you wish to support older CMake versions for this project. For more information run "cmake --help-policy CMP0000". This warning is for project developers. Use -Wno-dev to suppress it. -- Configuring incomplete, errors occurred! See also "/home/edu/workplace/yuenki/ykrecovery/build/CMakeFiles/CMakeOutput.log". See also "/home/edu/workplace/yuenki/ykrecovery/build/CMakeFiles/CMakeError.log". Makefile:7: recipe for target 'configure' failed make: *** [configure] Error 1
最新发布
06-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值