2012-07-16 61 views
18

我實際上正在閱讀LFS書籍(版本7.1),並在第53頁被封鎖。嘗試編譯gcc,我嘗試了以下命令:Gcc編譯「無法計算目標文件的後綴:無法編譯」

./configure --target=$LFS_TGT --prefix=$LFS/build/gcc-build --disable-nls\ 
--disable-shared --disable-multilib --disable-decimal-float --disable-threads\ 
--disable-libmudflap --disable-libssp --disable-libgomp --disable-libquadmath\ 
--disable-target-libiberty --disable-target-zlib\ 
--enable-languages=c\ 
--without-ppl --without-cloog\ 
--with-mpfr-include=$LFS/source/mpfr/src 
--with-mpfr-lib=$LFS/source/mpfr/src/.libs\ 
--with-gmp-include=/mnt/LFS/source/gmp\ 
--with-gmp-lib=/mnt/LFS/source/gmp/.libs\ 
--with-mpc-include=/mnt/LFS/source/mpc/src\ 
--with-mpc-lib=/mnt/LFS/source/mpc/src/.libs 

運行gcc的配置腳本(當然我已經編譯了mpfr,mpc和gmp)。 但是,一旦我推出:

make -j4 

我得到以下錯誤:

checking for suffix of object files... configure: error: in `/mnt/LFS/source/gcc-4.6.2/x86_64-lfs-linux-gnu/libgcc': 
configure: error: cannot compute suffix of object files: cannot compile 
See `config.log' for more details. 
make[1]: *** [configure-target-libgcc] Error 1 

我想谷歌它,並試圖找到我的解決方案,但毫無效果。有誰知道我爲什麼會遇到這個錯誤?

+0

當配置嘗試編寫一些測試程序發生的情況。 [此鏈接](http://gcc.gnu.org/wiki/FAQ#configure_suffix)可能會有用。 – ArjunShankar 2012-07-16 10:10:49

+2

*有關更多詳細信息,請參閱'config.log'。* - 好建議,這就是它出現在錯誤消息中的原因。 – DevSolar 2012-07-16 12:26:40

+0

感謝您的鏈接。但是我嘗試了所有的東西,而且我也沒有弄清楚問題可能來自哪裏。一些論壇說這是一個GCC的錯誤,它不讀取mpc或mpfr的庫文件。我會再試一次。無論如何感謝 – 2012-07-19 21:53:26

回答

13

當測試程序試圖鏈接到libmpc/libmpfr/libgmp時,此問題是由dyanmic鏈接庫路徑問題導致的。

追加下面的環境變量,讓LD鏈接對正確所以文件:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/mpc/lib/ 

,然後再次嘗試建立海灣合作委員會。

+0

你能舉一個這樣的路徑'/ path/to/mpc/lib /'的例子嗎?或者我怎麼找到它? – WebQube 2014-08-08 09:59:25

+0

@WebQube你不能執行'sudo find/-iname「libmpc.so」'?這將讓你知道路徑或運行命令'whereis libmpc.so'或'locate libmpc.so'。 – enthusiasticgeek 2014-10-21 09:13:30

+0

雖然有影響 - 正如我所知,mpc庫在* nix系統上並未默認安裝,您可能需要手動安裝它 - 實際路徑取決於您傳遞給'configure --prefix =/xx/xx' ,默認情況下配置腳本會安裝到'/ user/local/lib /' – Fei 2015-11-18 04:59:50

8

「*建築GCC是不平凡的,但如果你遵循謹慎 很多人衝進試圖建立它的指示,而不正確讀取安裝文檔,使這些常見的錯誤之一以上並不困難。

1)不要的./configure從運行gcc的src目錄(這是不支持)=>你需要運行從GCC源目錄之外

2)注意配置:如果GCC動態鏈接的前提條件庫( GMP/MPFR/MPC),那麼在構建gcc和使用安裝的編譯器時,共享庫必須位於動態鏈接器的路徑(LD_LIBRARY_PATH)中。*「

簡單的例子(不存在動態鏈接到GMP/MPFR/MPC):

tar xzf gcc-4.8.0.tar.gz 
cd gcc-4.8.0 
./contrib/download_prerequisites 
cd .. 
mkdir objdir 
cd objdir 
$PWD/../gcc-4.8.0/configure --prefix=/opt/gcc-4.8.0 
make 
make install 

來源: Advogato Doc - 可以從許多不同的原因產生 GNU Doc

+1

沒有動態鏈接的建築投票,它真的讓生活變得輕鬆。 – TwilightSun 2015-03-16 06:53:32

3

此錯誤消息。在下面的例子中找出哪一個檢查日誌文件'/home/manu/gcc/gcc/i686-pc-linux-gnu/libgcc/config.log'的最好方法。或者在原始海報案例'/mnt/LFS/source/gcc-4.6.2/x86_64-lfs-linux-gnu/libgcc'中查找最後一個錯誤行。

報價GCC FAQ:http://gcc.gnu.org/wiki/FAQ#configure_suffix

Like any of the GNU projects, GCC is using the GNU autotools to commonly configure the compilation for the specifics of the build system. The configure script thereby uses small test programs - usually called conftest.c - to test if certain functions and/or features are available. If the compilation of such a test program fails, you'll see an error message like:

checking for suffix of object files... configure: error: in 
`/home/manu/gcc/gcc/i686-pc-linux-gnu/libgcc': configure: error: 
cannot compute suffix of object files: cannot compile See `config.log' 
for more details. make[2]: *** [configure-stage1-target-libgcc] Error 
1 make[2]: Leaving directory `/home/manu/gcc/gcc' 

This error message is quite misleading and frequently the problem has nothing to do with the message. You have to check the file 'config.log' in the directory where the error occurred. In the example above, you would have to check the 'config.log' file in the directory '/home/manu/gcc/gcc/i686-pc-linux-gnu/libgcc'. There might be several test programs that failed during the configuration, but some of these failures are non-critical. Check for the last error entry in the file.

Common causes for this error message are:

  • Required libraries for the GCC build are missing, specifically MPFR, GMP and MPC. If installed as shared libraries they must be in the runtime linker's search path so they can be found. Please, follow the instructions in the answer to Why does my ./configure and make fail?

  • The compiler crashed. For example, if there is an error such as 'conftest.c: internal compiler error:', this indicates a bug in the compiler. If you are using an unmodified version of GCC, please follow the procedure to report the bug.