博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Ubuntu下boost库的编译安装步骤及卸载方法详解
阅读量:4227 次
发布时间:2019-05-26

本文共 1172 字,大约阅读时间需要 3 分钟。

最近由于编译一个程序用到了C++的库,所以便安装了这个库。但是,其中遇到了一些小问题。所以记录下来,以供别人参考。

首先说一下我的环境: 12.04 32bit,  gcc 4.6.3

其实在ubuntu下,可以用一下命令直接安装

sudo apt-get install libboost-dev

但是,我这样安装以后,编译程序时出现了很多错误,而且都是系统文件的错误。我开始以为是我的boost库版本不对,后来换了好几个版本,都出现了 同样的问题。后来,自己编译了一个boost.1.42。然后程序就顺利通过了。后来想了一下原因,可能是因为从上面的命令默认安装的boost在编译打 包时没有开启mpi这个功能。而我的程序需要这个功能。以下说一下安装的简要步骤(我编译了boost1.42和boost1.50,两者安装方法相同, 以后者为例):  先下载安装一下依赖文件:

apt-get install mpi-default-dev  #安装mpi库     apt-get install libicu-dev     #支持正则表达式的UNICODE字符集     apt-get install python-dev     #需要python的话     apt-get install libbz2-dev

1.下载boost1.53源文件

2.解压后,进入boost_1_53_0目录,执行:

./bootstrap.sh

3.(重点)修改  tools/build/v2/user-config.jam文件,在最后面加上一行“using mpi ;”(注意mpi后面有个空格,然后一个分号 )

4. 执行:

./b2

(或者:
./bjam -a -sHAVE_ICU=1  #-a参数,代表重新编译,-sHAVE_ICU=1代表支持Unicode/ICU

5. 执行:

sudo ./b2  install

以上便是全部安装过程,因为网上提到的比较多,所以此处从略。重点想提的是第三步,务必记得。不过,如果你的程序不需要mpi这个功能,那也就不重要了。 应用默认设置即可。而且,第四步,执行时可以在后面家prefix参数,如果不加,装好后,默认的头文件在/usr/local/include /boost目录下。库文件在/usr/local/lib/目录下。默认不用修改。

如果编译好程序后,在运行时提示无法加载某个库文件,则把/usr/local/lib下的所有boost的库文件mv到/usr/lib目录下就可以了。

默认安装头文件在目录/usr/local/include,而库文件在目录/usr/local/lib。也很简单,直接将以上两个目录中有关boost的内容删除就可以了。

更多详情可参考boost官方网站:

转载地址:http://fecqi.baihongyu.com/

你可能感兴趣的文章
Data Structures for Game Programmers
查看>>
Hacking Google Maps and Google Earth
查看>>
Code Design for Dependable Systems: Theory and Practical Applications
查看>>
Elements of Information Theory
查看>>
Mastering Data Warehouse Aggregates: Solutions for Star Schema Performance
查看>>
Digital Multimedia Perception and Design
查看>>
Dreamweaver 8 All-in-One Desk Reference For Dummies
查看>>
JavaScript Design
查看>>
Beginning Mac OS X Tiger Dashboard Widget Development
查看>>
Professional Live Communications Server
查看>>
Microsoft Exchange Server 2003 Advanced Administration
查看>>
Performance Analysis of Communications Networks and Systems
查看>>
SQL Server CE Database Development with the .NET Compact Framework
查看>>
Service Design for Six Sigma: A Roadmap for Excellence
查看>>
Maximum Security (3rd Edition)
查看>>
Discovering Knowledge in Data: An Introduction to Data Mining
查看>>
Computer Applications in Pharmaceutical Research and Development
查看>>
Software Measurement and Estimation: A Practical Approach
查看>>
Microsoft SQL Server 2005 Express Edition For Dummies
查看>>
Excel Pivot Tables Recipe Book: A Problem-Solution Approach
查看>>