CentOS6.5 下編譯Ceph源碼

引言

ceph源碼編譯不是一件很容易的事情,中間報了不少錯誤,好比對C++11的依賴,對BOOST的依賴以及大量其餘庫的依賴,這些過程都要一一解決。本文對編譯的過程進行了一個詳細的說明,並對碰到的問題進行了記錄。 c++

具體過程
git

1. 源碼下載

git clone https://github.com/ceph/ceph github

2. 編譯
web

./autogen.sh
./configure

環境檢查的過程當中報以下錯誤 shell


系統報錯,缺乏C++11的支持。須要升級GCC版本以支持C++11。 我諮詢過使用CentOS7系列的同窗,他們自帶的GCC是高版本的,能夠支持C++11. bootstrap

3. GCC c++11支持
多線程

wget http://ftp.gnu.org/gnu/gcc/gcc-4.8.1/gcc-4.8.1.tar.gz
tar xzf gcc-4.8.1.tar.gz  
cd gcc-4.8.1  
./contrib/download_prerequisites    //安裝依賴庫
cd ..  
mkdir build_gcc4.8.1
cd build_gcc4.8.1
../configure --prefix=/usr  -enable-checking=release --enable-languages=c,c++ --disable-multilib
make -j8
sudo make install

4. 編譯Ceph源碼
編譯的過程當中一樣出現了不少問題
app

configure: error: in `/home/ceph/ceph-src/ceph':
configure: error: libsnappy not found
See `config.log' for more details.
------------------------------------------------------------------------------------

configure: error: in `/home/ceph/ceph-src/ceph':
configure: error: libleveldb not found
See `config.log' for more details.
-------------------------------------------------------------------------------------
checking blkid/blkid.h usability... no
checking blkid/blkid.h presence... no
checking for blkid/blkid.h... no
configure: error: blkid/blkid.h not found (libblkid-dev, libblkid-devel)
-------------------------------------------------------------------------------------
checking libudev.h usability... no
checking libudev.h presence... no
checking for libudev.h... no
configure: error: libudev.h not found (libudev-dev, libudev-devel)
-------------------------------------------------------------------------------------
checking for malloc in -ltcmalloc... no
configure: error: in `/home/ceph/ceph-src/ceph':
configure: error: no tcmalloc found (use --without-tcmalloc to disable)
-------------------------------------------------------------------------------------
checking for FCGX_Init in -lfcgi... no
checking for LIBFUSE... yes
checking atomic_ops.h usability... no
checking atomic_ops.h presence... no
checking for atomic_ops.h... no
configure: error: in `/home/ceph/ceph-src/ceph':
configure: error: no libatomic-ops found (use --without-libatomic-ops to disable)
See `config.log' for more details.
-------------------------------------------------------------------------------------
checking xfs/xfs.h usability... no
checking xfs/xfs.h presence... no
checking for xfs/xfs.h... no
configure: error: xfs/xfs.h not found (--without-libxfs to disable)
----------------------------------------------------------------------------------------
Boost random library not found.

..........................................


主要採用以下辦法解決 dom

4.1先把能安裝的依賴包給安裝 curl

sudo yum install make automake autoconf  boost-devel fuse-devel gcc-c++ libtool libuuid-devel libblkid-devel keyutils-libs-devel cryptopp-devel fcgi-devel libcurl-devel expat-devel gperftools-devel libedit-devel libatomic_ops-devel snappy-devel leveldb-devel libaio-devel xfsprogs-devel git libudev-devel libcrypto++-dev libcrypto++-utils
4.2 yum找不到,手工rpm安裝

4.3 部分包不須要,直接without
./configure  --without-tcmalloc  --without-libatomic-ops

4.4 BOOST 庫缺失問題 

最後一個問題就是boost random lib can not found問題
yum顯示boost 和boost dev都有安裝,爲何boost庫有一部分存在,有一部分沒有呢。無奈之下采用編譯boost源碼的方法重裝BOOST
[root@gnop029-ct-zhejiang_wenzhou-16-12 home]# ls
boost_1_59_0  boost_1_59_0.tar.gz  c11  ceph  ceph.log  civetweb  dlftp  gcc4.7_build.tar.bz2  gcc-4.8.1  gcc-4.8.1.tar.bz2  usr  wget-log

 ./bootstrap.sh
 ./bjam -sTOOLS=gcc install


5 最後對ceph源碼進行

./autogen.sh
./configure
make

此處一樣出現了不少問題,編譯過程當中出現了大量undefined reference boost庫的狀況。


可是我在/usr/local/中能夠找到boost的頭文件以及二進制庫。
因而追查makefile文件,發現其中涉及到的BOOST庫內容以下:

BOOST_PROGRAM_OPTIONS_LIBS = -lboost_program_options-mt 
BOOST_RANDOM_LIBS = -lboost_random 
BOOST_REGEX_LIBS = -lboost_regex-mt 
BOOST_THREAD_LIBS = -lboost_thread-mt
因而去相關路徑下找庫,發現regex,thread庫後面都是沒有-mt後綴的


上網查資料發現,帶mt和不帶mt,分別意味這對多線程的支持。不由讓我想到在WINDOWS 平臺下開發時,在VS2010下進行項目配置時,一樣會涉及到對運行時庫配置時,也有mutlithread版本的。應是相似道理。因而我對boost進行了從新編譯。

./bjam --TOOLS=gcc  --build-type=complete  --layout=tagged  install


用complete的模式進行編譯,在相關路徑下能夠發現對應的二進制文件:能夠發現採用新模式編譯後,不少庫的release版本,debug版本,多線程支持版本都編譯出來了,想用哪一個用那個。



最後,重複步驟5,編譯ceph.


------------------------------------------------------------------------------------------------------------

在後來的編譯中,mon,osd,mds等等都編譯成功,卻發現rgw沒有編譯出來。經過顯示的增長
./configure --with-radosgw,得知了錯誤,是缺乏fcgi的相關依賴。可是系統中已經安裝fcgi因而清理重裝。

[root@gnop029-ct-zhejiang_wenzhou-16-12 yum.repos.d]# sudo yum install fcgi-devel

58 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package fcgi-devel.x86_64 0:2.4.0-12.el6 will be installed
--> Processing Dependency: fcgi = 2.4.0-12.el6 for package: fcgi-devel-2.4.0-12.el6.x86_64
--> Processing Dependency: libfcgi.so.0()(64bit) for package: fcgi-devel-2.4.0-12.el6.x86_64
--> Processing Dependency: libfcgi++.so.0()(64bit) for package: fcgi-devel-2.4.0-12.el6.x86_64
--> Running transaction check
---> Package fcgi.x86_64 0:2.4.0-10.el6 will be installed
---> Package fcgi-devel.x86_64 0:2.4.0-12.el6 will be installed
--> Processing Dependency: fcgi = 2.4.0-12.el6 for package: fcgi-devel-2.4.0-12.el6.x86_64
--> Finished Dependency Resolution
Error: Package: fcgi-devel-2.4.0-12.el6.x86_64 (epel)
           Requires: fcgi = 2.4.0-12.el6
           Available: fcgi-2.4.0-10.el6.x86_64 (Ceph)
               fcgi = 2.4.0-10.el6
Error: Package: fcgi-devel-2.4.0-12.el6.x86_64 (epel)
           Requires: fcgi = 2.4.0-12.el6
           Installing: fcgi-2.4.0-10.el6.x86_64 (Ceph)
               fcgi = 2.4.0-10.el6
 You could try using --skip-broken to work around the problem


將yum.repo.d文件夾下全部的repo文件刪除,只保留163的源,從新更新fcgi。後來編譯的過程當中又提示
rgw/rgw_fcgi.cc:10:22: fatal error: fcgiapp.h: No such file or directory
 # include "fcgiapp.h"
                      ^
compilation terminated.
因而又安裝fcgi-devel,後成功找到頭文件,並進行編譯。
相關文章
相關標籤/搜索