博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何在Ubuntu上安装Boost
阅读量:2380 次
发布时间:2019-05-10

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

本文翻译自:

I'm on Ubuntu, and I want to install Boost. 我在Ubuntu上,并且想安装Boost。 I tried with 我尝试过

sudo apt-get install boost

But there was no such package. 但是没有这样的软件包。 What is the best way to install Boost on Ubuntu? 在Ubuntu上安装Boost的最佳方法是什么?


#1楼

参考:


#2楼

You can use apt-get command (requires sudo ) 您可以使用apt-get命令(需要sudo

sudo apt-get install libboost-all-dev

Or you can call 或者你可以打电话

aptitude search boost

find packages you need and install them using the apt-get command. 查找所需的软件包并使用apt-get命令安装它们。


#3楼

Installing Boost on Ubuntu with an example of using boost::array : 以使用boost::array的示例在Ubuntu上安装Boost:

Install libboost-all-dev and aptitude: 安装libboost-all-dev和aptitude:

sudo apt install libboost-all-devsudo apt install aptitudeaptitude search boost

Then paste this into a C++ file called main.cpp : 然后将其粘贴到一个名为main.cpp的C ++文件中:

#include 
#include
using namespace std;int main(){ boost::array
arr = {
{1,2,3,4}}; cout << "hi" << arr[0]; return 0;}

Compile like this: 像这样编译:

g++ -o s main.cpp

Run it like this: 像这样运行它:

./s

Program prints: 程序打印:

hi1

#4楼

Get the version of Boost that you require. 获取所需的Boost版本。 This is for 1.55 but feel free to change or manually download yourself: 这是1.55,但可以随时更改或手动下载:

wget -O boost_1_55_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.gz/downloadtar xzvf boost_1_55_0.tar.gzcd boost_1_55_0/

Get the required libraries, main ones are icu for boost::regex support: 获得所需的库,主要的是icu以获取boost::regex支持:

sudo apt-get updatesudo apt-get install build-essential g++ python-dev autotools-dev libicu-dev build-essential libbz2-dev libboost-all-dev

Boost's bootstrap setup: Boost的引导程序设置:

./bootstrap.sh --prefix=/usr/

Then build it with: 然后用:

./b2

and eventually install it: 并最终安装它:

sudo ./b2 install

#5楼

Actually you don't need "install" or "compile" anything before using Boost in your project. 实际上,在项目中使用Boost之前,您不需要“安装”或“编译”任何内容。 You can just download and extract the Boost library to any location on your machine, which is usually like /usr/local/ . 您可以将Boost库下载并解压缩到计算机上的任何位置,通常类似于/usr/local/

When you compile your code, you can just indicate the compiler where to find the libraries by -I . 编译代码时,您可以通过-I指示编译器在何处查找库。 For example, g++ -I /usr/local/boost_1_59_0 xxx.hpp . 例如, g++ -I /usr/local/boost_1_59_0 xxx.hpp


#6楼

Get the version of Boost that you require. 获取所需的Boost版本。 This is for 1.55 but feel free to change or manually download yourself: 这是1.55,但可以随时更改或手动下载:

wget -O boost_1_55_0.tar.gz http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.gz/downloadtar xzvf boost_1_55_0.tar.gzcd boost_1_55_0/

Get the required libraries, main ones are icu for boost::regex support: 获得所需的库,主要的是icu以获取boost :: regex支持:

sudo apt-get updatesudo apt-get install build-essential g++ python-dev autotools-dev libicu-dev libbz2-dev

Boost's bootstrap setup: Boost的引导程序设置:

./bootstrap.sh --prefix=/usr/local

If we want MPI then we need to set the flag in the user-config.jam file: 如果我们需要MPI,则需要在user-config.jam文件中设置标志:

user_configFile=`find $PWD -name user-config.jam`echo "using mpi ;" >> $user_configFile

Find the maximum number of physical cores: 查找最大物理核数:

n=`cat /proc/cpuinfo | grep "cpu cores" | uniq | awk '{print $NF}'`

Install boost in parallel: 并行安装boost:

sudo ./b2 --with=all -j $n install

Assumes you have /usr/local/lib setup already. 假设您已经设置了/ usr / local / lib if not, you can add it to your LD LIBRARY PATH : 如果没有,您可以将其添加到LD LIBRARY PATH中

sudo sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/local.conf'

Reset the ldconfig: 重置ldconfig:

sudo ldconfig

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

你可能感兴趣的文章
mysql性能优化-查询(Query)优化-2
查看>>
MySQL分区表的使用
查看>>
网页中输出漂亮格式的Php数组神器
查看>>
Android WebView挂马漏洞--各大厂商纷纷落马
查看>>
MongoDB 地理位置索引的实现原理
查看>>
MongoDB与MySQL的插入、查询性能测试
查看>>
深入理解OAuth2.0协议
查看>>
https原理:证书传递、验证和数据加密、解密过程解析
查看>>
MySQL在大型网站的应用架构演变
查看>>
sphinx教程1__mysql sphinx引擎插件式热安装
查看>>
sphinx教程2__安装、配置和使用
查看>>
ttserver 缓存使用和过期设置
查看>>
php pconnect 长连接原理
查看>>
php memcached使用中的坑
查看>>
php变量引用和计数_refcount_gc和is_ref_gc
查看>>
windows环境下php和Php扩展编译,扩展dll文件编译
查看>>
magento 验证码
查看>>
magento 获取自定义产品属性和属性值
查看>>
magento获取产品的好评率
查看>>
magento 获取产品的销售量
查看>>