Ubuntu编译安装boost并在eclipse C/C++中使用


1.从boost官网下载boost 1.46.1

2.执行 apt-get install build-essential (目的是为了安装好象gcc,g++等一些工具进行编译)
      注:我是在root用户下进行的操作,普通用户执行 sudo apt-get install build-essential

3.解压boost库到/usr/share/
      將下载好的boost 1.46.1.tar.gz(我用的是这个版本) 复制到/usr/share/ 目录下,然后解压,会自动生成一个boost_1_46_1这个文件夹(或者用命令解压,这里就不提了,可以自己去查解压命令)

4.编译bjam(这个东东是用来编译boost库的)
      编译之前先做如下操作,由于这版本是编译msvc版的bjam,我们把它改成gcc版的bjam......
      进入boost1.46.1解压目录找到bootstrap.bat 用记事本打开,然后修改:
      第13行將call .\build.bat > ..\..\..\bjam.log 改为call .\build.bat gcc > ..\..\..\bjam.log
     第33行將set toolset=msvc改为set toolset=gcc
     保存退出,然后双击 bootstrap.sh在终端中执行,稍等片刻会在boost_1_46_1中生成bjam
5.编译boost库: 在终端中进入/usr/share/boost_1_46_1目录
     在终端中输入 cd /usr/share/boost_1_46_1
     然后我在root用户下输入 ./bjam toolset=gcc --layout=tagged --build-type=complete stage 进行完全编译
     (普通用户的话执行: sudo ./bjam toolset=gcc --layout=tagged --build-type=complete stage )
      经过漫长的等 待,命令执行完毕后,将会生成所有版本的库,并存储在:
         /usr/share/boost_1_46_1/stage
6.boost 已经编译好了,下面调用boost库
    1.在/usr/include/下生成一个boost库的include文件夹连接:
       ln -s /usr/share/boos t_1_46_1/boost /usr/include/boost
    2.在/usr/lib/ 下生成所有boost编译出的lib库文件的对应连接 切换到stage目录下,执行
       find $PWD/lib/*.* -type f -exec ln -s {} /usr/lib/ \;
       (普通用户执行: sudo find $PWD/lib/*.* -type f -exec ln -s {} /usr/lib/ \; )

执行完以上操作就算ok了

这不是一篇向导,全面的向导请看这里 (http://goo.gl/XcAf)。
这仅是一篇笔记。这里用bjam方式 进行编译。

  1. 下载boost。(http://cdnetworks-kr-1.dl.sourceforge.net/project/boost/boost/1.42.0/boost_1_42_0.tar.bz2)
  2. 解压到指定文件夹,我是将它解压到根目录下的一个sourcecode文件夹下。     /home/volnet/sourcecode/boost_1_42_0
  3. 启动终端(ctrl+f2,输入“gnome-terminal”)。生成bjam脚本。     ./bootstrap.sh --prefix=/home/volnet/sourcecode/boost_install如果不带--prefix参数的话(推荐 ),默认的路径是/usr/local/include和/usr/local/lib     ./bootstrap.sh使用--help参数可以查看帮助,用-h可以查看简要帮助。     ./bootstrap.sh --help生成脚本bjam,已经存在的脚本将被自动备份。
    www.bkjia.com@Ubuntu:~/sourcecode/boost_1_42_0$ ./bootstrap.sh --prefix=/home/volnet/sourcecode/boost_install/
    Building Boost.Jam with toolset gcc... tools/jam/src/bin.linuxx86/bjam
    Detecting Python version... 2.6
    Detecting Python root... /usr
    Unicode/ICU support for Boost.Regex?... /usr
    Backing up existing Boost.Build configuration in project-config.jam.4
    Generating Boost.Build configuration in project-config.jam...

    Bootstrapping is done. To build, run:

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

       - Command line help:
         ./bjam --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
  • 1
  • 2
  • 下一页

相关内容