小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

編譯安裝GCC 5.2.0

 gljin_cn 2016-09-19

原文  http://blog./note/install-gcc-5.2.0-from-source.html

記錄編譯GCC 5.2.0時遇到的問題和解決方法,以備日后查詢。

平時使用的服務(wù)器是CentOS5,自帶的gcc編譯器還是8年前發(fā)布的4.1.2版本,完全沒法寫C++11的代碼,因為不想升級操作系統(tǒng),只好自己下載源碼編譯。

安裝過程挺dan疼的,只好記錄下來。

安裝依賴庫

GCC依賴于gmp 4.2+, mpfr 2.4+和mpc 0.8+,這里直接下載安裝最新的版本。

為了省事,所有的庫都直接裝到/usr/local目錄下的對應(yīng)目錄。

安裝gmp 6.0

wget https:///download/gmp/gmp-6.0.0a.tar.bz2
tar xvf gmp-6.0.0a.tar.bz2
cd gmp-6.0.0
./configure
make -j4
make install

安裝mpfr 3.1.3

mpfr依賴于gmp。

wget http://www./mpfr-current/mpfr-3.1.3.tar.bz2
tar xvf mpfr-3.1.3.tar.bz2
cd mpfr-3.1.3
./configure --with-gmp-include=/usr/local/include     --with-gmp-lib=/usr/local/lib
make -j4
make install

安裝mpc 1.0.3

mpc依賴于gmp和mpfr。

wget ftp://ftp./gnu/mpc/mpc-1.0.3.tar.gz
tar xvf mpc-1.0.3.tar.gz
cd mpc-1.0.3
./configure --with-mpfr-include=/usr/local/include     --with-mpfr-lib=/usr/local/lib     --with-gmp-include=/usr/local/include     --with-gmp-lib=/usr/local/lib
make -j4
make install

安裝GCC

編譯

建議先閱讀下官方的 安裝文檔 。

下載GCC并解壓。

wget ftp://ftp./gnu/gcc/gcc-5.2.0/gcc-5.2.0.tar.bz2
tar xvf gcc-5.2.0.tar.bz2
cd gcc-5.2.0

先unset若干個系統(tǒng)變量,以免出現(xiàn)某些宏找不到的情況。

unset CPLUS_INCLUDE_PATH LIBRARY_PATH

配置GCC

./configure     --with-gmp-include=/usr/local/include     --with-gmp-lib=/usr/local/lib     --with-mpfr-include=/usr/local/include     --with-mpfr-lib=/usr/local/lib     --with-mpc-include=/usr/local/include     --with-mpc-lib=/usr/local/lib     --enable-languages=c,c++     --enable-threads=posix     --disable-multilib

詳細的配置項說明可參考 安裝文檔 ,這里只編譯c和c++的編譯器。

然后 make -j8 ,啟用多線程編譯。

測試

先安裝dejagnu: yum install dejagnu 。

然后運行如下命令:

make -j8 check-gcc

查看測試結(jié)果:

./contrib/test_summary

安裝

如果編譯順利通過, make install 即可。

gcc和g++默認被安裝到 /usr/local/bin 目錄下,libgcc和libstdc++默認被安裝到/usr/local/lib64 (x64)。

記得更下下動態(tài)庫緩存。

ldconfig

可能遇到的問題

XXXX not defined

遇到某個宏沒有定義的情況,先unset C_INCLUDE_PATH 再嘗試。

braced spec is invalid

很dan疼的一個問題,搜遍了全網(wǎng)也沒見有比較正式的解決方案。目前看上去比較靠譜的方法可參考 這里 ,具體操作就是手動改一下某個specs文件。

我這里是 host-x86_64-unknown-linux-gnu/gcc/specs ,把其中所有的%:sanitize(xxx) 改為 fsanitize=xxx 。

測試C++11

寫一個腦殘的cpp測試下新安裝的編譯器。

#include <atomic>
#include <iostream>
using namespace std;

int main() {
    atomic<long long> num(1L << 14);
    cout << ++num << endl;
}

編譯并運行:

/usr/local/bin/g++ -std=c++11 b.cpp -o b
LD_LIBRARY_PATH=/usr/local/lib64 ./b


--------------------------------------------------------------------------
編譯中的問題:
sudo gedit config.log  # 查看日志,搜索"error"

# issue: configure: error: C++ compiler missing or inoperational
# 沒有C++編譯器
yum install gcc-c++

# issue: conftest.cpp:11:2: error: #error -static-libstdc++ not implemented
# 沒有C,C++靜態(tài)庫
yum install glibc-static libstdc++-static -y
# 但報"No package libstdc++-static available",即沒有-static-libstdc++源,問題仍存在。
# "checking whether g++ accepts -static-libstdc++ -static-libgcc"時報出的,可忽略。

# issue: conftest.c:10:25: error: isl/version.h: No such file or directory
# 沒有ISL
wget ftp://gcc./pub/gcc/infrastructure/isl-0.12.2.tar.bz2
tar jxvf isl-0.12.2.tar.bz2
cd isl-0.12.2; ./configure
make; make install
cd ..

# issue: ./conftest: error while loading shared libraries: libisl.so.10: cannot open shared object file: No such file or directory
# 在"/usr/local/lib"目錄下,怎么就它找不到。加到"/etc/ld.so.conf"或用"LD_LIBRARY_PATH"。
vi /etc/ld.so.conf  # 添加"/usr/local/lib"
ldconfig  # 重建/etc/ld.so.cache
# 自問:于**Issue 1**里,已經(jīng)單獨在"/etc/ld.so.conf.d"下建個"*.conf"添加過"/usr/local/lib",怎么沒效果呢?
# 自答:之后安裝的ISL,沒重新ldconfig,所以找不到了?當時沒查,不能確認。用以下命令:
strings /etc/ld.so.cache | grep libisl  # 查看
# 之后,刪除了"/etc/ld.so.conf"內(nèi)的添加,也不再有該問題。

# issue: conftest.c:10:27: error: cloog/version.h: No such file or directory
# 沒有CLooG
wget ftp://gcc./pub/gcc/infrastructure/cloog-0.18.1.tar.gz
tar zxvf cloog-0.18.1.tar.gz
cd cloog-0.18.1; ./configure
make; make install
cd ..

# issue: conftest.c:15: error: 'choke' undeclared (first use in this function)
# "checking for version 0.17.0 of CLooG"失敗報出的,沒問題。

 

 

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多