2011-03-01 67 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