让GMP与GCC 4.5.2一起工作 [英] Getting GMP to work with GCC 4.5.2

查看:218
本文介绍了让GMP与GCC 4.5.2一起工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用来自 http:/ /crossgcc.rts-software.org/doku.php?id=i386linuxgccformac



我在Intel Mac(10.6.6,x86_64)上编译为:gmp,mpfr,mpc为交叉编译器为32位(因为我在64位Mac上),但我得到了

  ld:warning:选项-s已过时并被忽略
ld:warning:忽略文件/gmp1/lib/libmpc.dylib,文件是为不支持的文件格式构建的,而不是被链接的体系结构(i386)
ld:warning:忽略文件/gmp1/lib/libmpfr.dylib,文件是为不支持的文件格式而构建的,而不是被链接的体系结构(i386)
ld:warning:忽略文件/ gmp1 / lib /libgmp.dylib文件是为不支持的文件格式构建的,它不是被链接的架构(i386)

在编译GCC时:

   -  prefi x = / usr / local / i386-linux-4.5.2 --target = i386-linux --enable-languages = c --without-headers --disable-shared --disable-threads --disable-nls  - 带有-gmp = / gmp1 --with-gmp-lib = / gmp1 --with-gmp-include = / gmp1 --with-mpfr = / gmp1 --with-mpfr-include = / gmp1 --with-mpfr- lib = / gmp1 --with-mpc = / gmp1 --with-mpc-lib = / gmp1 --with-mpc-include = / gmp1 

另外,如果我编译GMP:

  ./ configure --prefix = / gmp1 --host = i386-linux 

我得到:

  configure:警告:+ ------------------------------ ---------------------------- 
configure:警告:|无法确定全局符号前缀。
configure:警告:| link -dump -symbols输出不包含全局数据符号。
configure:警告:|将继续没有下划线。
configure:警告:|如果这是错误的,那么你会得到链接错误引用
configure:警告:|到___gmpn_add_n(注意三个下划线)。
configure:警告:|在这种情况下,请使用覆盖
configure来执行新建:警告:| ./configure gmp_cv_asm_underscore = yes
configure:WARNING:+ ----------------------------------- -----------------------
检查如何切换到只读数据部分... .data
检查汇编程序。类型指令...
检查汇编器.size指令...
检查汇编器本地标签前缀...警告:link -dump -symbols失败
configure:WARNING :无法确定本地标签,使用默认的L
L
检查汇编程序字节指令... .byte
检查如何定义32位字...链接:非法选项 - d


解决方案

我认为你对哪个软件包应该感到困惑要针对哪个平台进行编译:


  • GCC需要针对x86_64 MacOS X主机和i386-linux目标进行编译。 / p>


  • GMP,MPC和MPFR是GCC的运行时依赖项。因此他们也需要编译为GCC主机 - x86_64在你的情况下。因此,GMP configure命令中的 - host = i386-linux 选项不正确。




一般情况下,只有为GCC编译的程序中链接的库需要为交叉编译器目标(例如i386-linux)构建。 GMP和MPFR不是这样的库,除非你的程序实际上正在使用它们 - 在这种情况下,你需要有两个这样的库的副本,一个用于GCC,另一个用于目标的交叉构建。



编辑:



您是否考虑过使用 MacPorts的?它具有交叉编译器的所有依赖关系:


  • gmp-5.0.1


  • mpfr-3.0.0


  • libmpc-0.8.2

    对于 i386 :





    即使你不想使用这些,你仍然可以看看它们的Portfiles中的构建指令。



    底线是:


    • 应用这些库需要的任何补丁 - MacPorts已经做到了这一点。

    • 编译天秤座您的构建主机即为MacOSX / x86_64。这意味着在任何配置调用的 - host 选项中,您都应该是 - host = x86_64-darwin (或任何你的主人需要)。如果configure可以自行找出主机,则可以跳过 - host 选项。 p>使用 - host 编译GCC作为您的 build host (64位Mac OS X)和i386-linux的目标,例如 - 目标= I386-linux的。如果我是你的话,我只会简单地使用C和C ++语言的编译器。 本教程。它有一些关于如何用适当的glibc生成工作工具链的信息。



      也就是说,我认为你最好在a中安装合适的Linux发行版虚拟机,出于一大堆原因。是否有理由特别需要交叉编译器?你想用这个编译器做什么?


      I'm trying to make a cross compiler with the files from http://crossgcc.rts-software.org/doku.php?id=i386linuxgccformac

      I'm on an Intel Mac (10.6.6, x86_64) I compiled: gmp, mpfr, mpc for the cross compiler as 32bit (as I'm on a 64bit Mac) but I'm getting

      ld: warning: option -s is obsolete and being ignored
      ld: warning: ignoring file /gmp1/lib/libmpc.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
      ld: warning: ignoring file /gmp1/lib/libmpfr.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
      ld: warning: ignoring file /gmp1/lib/libgmp.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
      

      When compiling GCC with:

      --prefix=/usr/local/i386-linux-4.5.2 --target=i386-linux --enable-languages=c --without-headers --disable-shared --disable-threads --disable-nls --with-gmp=/gmp1 --with-gmp-lib=/gmp1 --with-gmp-include=/gmp1 --with-mpfr=/gmp1 --with-mpfr-include=/gmp1 --with-mpfr-lib=/gmp1 --with-mpc=/gmp1 --with-mpc-lib=/gmp1 --with-mpc-include=/gmp1
      

      Also, if I compile GMP with:

      ./configure --prefix=/gmp1 --host=i386-linux
      

      I get:

      configure: WARNING: +----------------------------------------------------------
      configure: WARNING: | Cannot determine global symbol prefix.
      configure: WARNING: | link -dump -symbols output doesn't contain a global data symbol.
      configure: WARNING: | Will proceed with no underscore.
      configure: WARNING: | If this is wrong then you'll get link errors referring
      configure: WARNING: | to ___gmpn_add_n (note three underscores).
      configure: WARNING: | In this case do a fresh build with an override,
      configure: WARNING: |     ./configure gmp_cv_asm_underscore=yes
      configure: WARNING: +----------------------------------------------------------
      checking how to switch to read-only data section... .data
      checking for assembler .type directive... 
      checking for assembler .size directive... 
      checking for assembler local label prefix... configure: WARNING: "link -dump -symbols" failure
      configure: WARNING: cannot determine local label, using default L
      L
      checking for assembler byte directive... .byte
      checking how to define a 32-bit word... link: illegal option -- d
      

      解决方案

      I think that you are confused about which package should be compiled for which platform:

      • GCC needs to be compiled for an x86_64 MacOS X host and an i386-linux target.

      • GMP, MPC and MPFR are runtime dependencies for GCC. Therefore they also need to be compiled for the GCC host - x86_64 in your case. Therefore, the --host=i386-linux option in the GMP configure command is incorrect.

      In general, only libraries that will be linked in the programs compiled by GCC need to be built for the cross-compiler target (e.g. i386-linux). GMP and MPFR are not such libraries, unless your programs are actually using them - in that case you will need to have two copies of such libraries, one for GCC and a cross-build for the target.

      EDIT:

      Have you considered using MacPorts? It has all the dependencies for your cross-compiler:

      There is also an older newlib-based cross-compiler for i386:

      Even if you do not want to use these, you can still have a look at the build instructions in their Portfiles.

      The bottom line is:

      • Apply whatever patches these libraries need - MacPorts already do that.

      • Compile the libraries for your build host i.e. MacOSX/x86_64. That means that in any --host options for their configure calls you should be something along the lines of --host=x86_64-darwin (or whatever your host needs). If configure can figure out the host on its own, you can skip the --host options altogether.

      • Compile GCC with --host being your build host (the 64-bit Mac OS X) and a target of i386-linux, e.g. --target=i386-linux. If I were you, I'd start simple with a compiler for the C and C++ languages only.

      See also this tutorial. It has some information on how to produce a working toolchain with a proper glibc.

      That said, I think that you'd be better off installing a proper Linux distribution in a virtual machine, for a whole bunch of reasons. Is there a reason for you to need a cross-compiler specifically? What do you want to do with that compiler?

      这篇关于让GMP与GCC 4.5.2一起工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆