CentOS 無法辨識已編譯的 boost 函式庫

CentOS 無法辨識已編譯的 boost 函式庫

我使用以下步驟建置並安裝了 boost:

# Boostrap and install
JOBS=`grep -c ^processor /proc/cpuinfo`
wget https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.bz2
tar xf boost_1_67_0.tar.bz2
cd boost_1_63_0
./bootstrap.sh
./b2 -d1 -j${JOBS} --with-thread --with-filesystem --with-python --with-regex -sHAVE_ICU=1 --with-program_options --with-system link=shared release toolset=gcc stage
./b2 -d1 -j${JOBS} --with-thread --with-filesystem --with-python --with-regex -sHAVE_ICU=1 --with-program_options --with-system link=shared release toolset=gcc install
sudo bash -c "echo '/usr/local/lib' > /etc/ld.so.conf.d/boost.conf"
sudo ldconfig

然後,我嘗試建立使用 boost 的 mapnik。我結帳馬普尼克並運行./bootstrap.sh./configure。我收到錯誤“找不到 boost 檔案系統所需的標頭或共享庫”。配置的boost部分如下:

Searching for boost libs and headers... (cached) 
Found boost libs: mason_packages/.link/lib
Found boost headers: mason_packages/.link/include
Checking for C++ header file boost/version.hpp... yes
Checking for Boost version >= 1.61... yes
Found boost lib version... 
Checking for C++ library boost_system... no
Could not find required header or shared library for boost system
Checking for C++ library boost_filesystem... no
Could not find required header or shared library for boost filesystem
Checking for C++ library boost_regex... yes
Checking for C++ library boost_program_options... yes
ValueError: invalid literal for int() with base 10: '':
  File "/root/src/mapnik/SConstruct", line 1600:
    boost_version = [int(x) for x in env.get('BOOST_LIB_VERSION_FROM_HEADER').split('_')]

(建置步驟由 慶三

為什麼系統找不到boost函式庫1.67?我不記得安裝過 boost 1.63。我已經編譯並安裝了1.67,但建置系統不使用它。系統在哪裡尋找系統的提升?我刪除了/usr/local/lib和/usr/lib64中的所有libboost_*文件,但仍然不知道系統在哪裡尋找boost。有人可以提供有關如何告訴系統新編譯的軟體的提示嗎?

答案1

Cent OS 7 用戶在這裡,也嘗試讓 Mapnik 使用可選依賴項進行構建,但是我的確實(似乎)識別了我更新的 Boost 構建。您可能已經克服了這個問題,迴避了它,或者忘記了它,但我還是提到這一點,以防它對您或其他人有幫助。

從我讀到的內容來看,這幾乎就像 Mapnik 希望/需要使用相同的編譯器建立依賴項,以便在 make/install 步驟期間識別這些依賴項。但是,如果您使用此方法,它實際上會建立一個替代的非預設編譯器,您必須在 shell 會話中指定該編譯器才能使用它來取代預設編譯器。

我使用這種方法來更新我的編譯器,建立 Boost,然後設定 Mapnik。所以它可能對你有用。

重要的。特別注意第二步中出現的export CC=和說明。export CXX=因為這是您覆蓋預設編譯器的地方,並且似乎大多數/所有依賴項都需要使用此編譯器建置。

首先,從 gcc6 系列取得更新的 gcc/g++ 編譯器,並支援 c++14:

## Instructions modified from here, I just changed the gcc version.. 
## https://linuxhostsupport.com/blog/how-to-install-gcc-on-centos-7/
## 
cd /root/downloads
screen -U -S gcc
wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-6.5.0/gcc-6.5.0.tar.gz
tar zxf gcc-6.5.0.tar.gz
cd gcc-6.5.0
## Install bzip2 if you don't have it yet..
yum install bzip2
## Install gcc prereqs..
./contrib/download_prerequisites
./configure --disable-multilib --enable-languages=c,c++
make -j 4
make install

接下來,從原始碼建置並安裝 Boost。此方法可能會導致再次安裝 Boost。但您需要知道它落在哪裡,以便在 Mapnik 的設定步驟中指定它:

## Create temporary links to the new gcc/g++ compiler resources.
## These disappear with your shell session but need to be in effect for both the Boost and Mapnik builds.
## 
export CC=/usr/local/bin/gcc
export CXX=/usr/local/bin/g++

cd /root/downloads
wget https://dl.bintray.com/boostorg/release/1.69.0/source/boost_1_69_0.tar.gz
tar -xzf boost_1_*
cd boost_1_*
## This prefix variable sets the install location for boost, knowing this location is important. 
## This was the location suggested by the instructions I followed, which I've lost, but this seems to be a standard alternative location.
./bootstrap.sh --prefix=/opt/boost
./b2 install --prefix=/opt/boost --with=all

現在 Boost 已安裝並位於此處:/opt/boost/

此時,在建置和安裝 Mapnik 時,您可以在設定步驟中指定更新的 Boost 版本,如下所示。

這很重要-如果您已重新啟動,或者已登出並重新登錄,則需要重複第二步頂部出現的export CC=和說明,以確保 Mapnik 使用與建置 Boost 相同的編譯器進行建置!export CXX=

./configure BOOST_LIBS=/opt/boost/lib BOOST_INCLUDES=/opt/boost/includes

希望這對某人有幫助!

相關內容