2011-03-01 69 views
2

我试图与该文件一个交叉编译器从http://crossgcc.rts-software.org/doku.php?id=i386linuxgccformac获得GMP与GCC 4.5.2

我的英特尔Mac上(10.6.6,x86_64的)我编的工作:GMP,MPFR ,MPC的交叉编译器为32位(因为我在64位的Mac),但我得到

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) 

当与GCC编译:

--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 

另外,如果我编译GMP有:

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

我得到:

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 

回答

6

我认为你是混淆有关的包装应为哪些平台编译:

  • GCC需要编译为x86_64的MacOS X的主机和I386-Linux目标。

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

一般来说,需要为交叉编译目标待建(例如I386-Linux)的只将在由GCC编译的程序被链接库。 GMP和MPFR不是这样的库,除非你的程序实际上在使用它们 - 在这种情况下,你需要有两个这样的库副本,一个用于GCC和一个跨目标版本。

编辑:

你有没有考虑过使用MacPorts?它为您的交叉编译所有的依赖:

也有一个较旧的基于newlib交叉编译器i386

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

的底线是:

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

  • 为编译主机(即MacOSX/x86_64)编译库。这意味着在配置调用的任何--host选项中,您应该沿着--host=x86_64-darwin(或任何您的主机需要的)行。如果configure可以自己找出主机,则可以完全跳过--host选项。

  • 编译GCC与--host被你构建宿主(64位的Mac OS X)和i386-Linux的一个目标,例如--target=i386-linux。如果我是你,我只会用C和C++语言的编译器开始。

另请参阅this tutorial。它有一些关于如何用适当的glibc生成工作工具链的信息。

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

+0

我有点困惑,请你举个例子 – Daniel 2011-03-09 12:13:19

+0

@thkala也gmp不允许--target被设置? – Daniel 2011-03-09 12:15:18

+0

@thkala我试过“./configure --prefix =/gmp1 --host = i386-apple-darwin10.6.0 --build = i386-linux --with-gmp =/gmp1 --with-mpfr =/gmp1”但它出现了上述错误(如问题中提到的) – Daniel 2011-03-09 12:21:12

0

难道编译GMP当您使用 “ABI = 32” 的选项?如果没有,我认为它将使用64位代码,即使主机/目标被指定为i386。

+0

是的,我确实使用ABI = 32 – Daniel 2011-03-09 06:59:26