Linux下boost_1_49_0 安裝以及相關問題解決

在linux下安裝boost_1_49
相關係統信息:ubantu12.04LTS ,boost_1_49_0php

1. 下載boost庫,到官網上下便可。http://www.boost.org/
下載完解壓便可

2. 權限設置:

我在安裝的過程當中出現了以下問題:權限不夠

administrator@ubuntu:~/source/boost_1_49_0$ ./bootstrap.sh
bash: ./bootstrap.sh: Permission denied

給予其權限:
chmod +x ./bootstrap.sh

在運行的過程當中,又出現權限不足的問題,繼續給予權限
administrator@ubuntu:~/source/boost_1_49_0$ ./bootstrap.sh
./bootstrap.sh: 1: ./bootstrap.sh: ./tools/build/v2/engine/build.sh: Permission denied

administrator@ubuntu:~/source/boost_1_49_0/tools/build/v2/engine$ chmod +x  ./build.sh


3. 編譯生成boost的編譯引擎

有了足夠的權限後,就能夠運行bootstrap.sh:編譯生成boost的編譯引擎

administrator@ubuntu:~/source/boost_1_49_0$ ./bootstrap.sh 
Building Boost.Build engine with toolset gcc... tools/build/v2/engine/bin.linuxx86/b2
Detecting Python version... 2.7
Detecting Python root... /usr
Unicode/ICU support for Boost.Regex?... not found.
Generating Boost.Build configuration in project-config.jam...

Bootstrapping is done. To build, run:

    ./b2
    
To adjust configuration, edit 'project-config.jam'.
Further information:

   - Command line help:
     ./b2 --help
     
   - Getting started guide: 
     http://www.boost.org/more/getting_started/unix-variants.html
     
   - Boost.Build documentation:
     http://www.boost.org/boost-build2/doc/html/index.html

其編譯了boost的編譯引擎(bjam/b2)。


4. 開始編譯boost程序

administrator@ubuntu:~/source/boost_1_49_0$ ./bjam --prefix==./prefix/install
Building the Boost C++ Libraries.


5. 安裝boost

administrator@ubuntu:~/source/boost_1_49_0$ ./b2 install

在安裝的時候,即拷貝BOOST生成的文件,又出現了許多權限問題,見控制檯輸出:
html

...failed common.copy /usr/local/lib/libboost_thread.a...
common.copy /usr/local/lib/libboost_timer.a
cp: cannot create regular file `/usr/local/lib/libboost_timer.a': Permission denied

因此就輸入了以下命令:
administrator@ubuntu:~/source/boost_1_49_0$ sudo ./b2 install

增長了權限後,文件確實拷貝成功,放於usr/local/....目錄下,可是使用的時候仍是說沒有權限使用boost,因此直接將普通用戶設置爲root權限 linux

administrator@ubuntu:~$ sudo vi /etc/passwd
administrator:x:0:0:Administrator,,,:/home/administrator:/bin/bash

  註銷從新登陸後,
root@ubuntu:~/source/ThreadPool# g++ -c Thread.cpp -o Thread

Thread類中但是使用到了boost中的文件的哈
#include <pthread.h>
#include <string>
#include <boost/function.hpp>
#include <boost/bind.hpp>

 

注:其實要是一開始就設置成root用戶,前面那些操做壓根就不會有什麼權限方面的問題哈。讀者在使用的時候建議先設置權限,避免其中的關於權限的問題。bootstrap

參考:http://www.eifr.com/article.php?id=743&act=printubuntu

相關文章
相關標籤/搜索