美文网首页C++从入门到放弃
boost在ubuntu16,windows10的安装

boost在ubuntu16,windows10的安装

作者: lixin_karl | 来源:发表于2019-07-18 15:00 被阅读0次

https://www.boost.org/ 下载boost文件

boost在Ubuntu下安装

tar xvzf boost_1_50_0.tar.gz

sudo ./bootstrap.sh

sudo ./b2

sudo ./b2 install --prefix=/usr/local

#include <iostream>
#include <string>
#include "boost/tuple/tuple.hpp"

int main() {
  boost::tuple<int,double,std::string> 
  triple(42,3.14,"The amazing tuple!"); 
  int i=boost::tuples::get<0>(triple);
  double d=triple.get<1>();
  std::string s=boost::get<2>(triple);
  std::cout<<s<<std::endl;
}

boost在windows下安装

Win10+Clion+boost+MinGW 配置

首先:

  • 下载MinGW 安装后,把gcc的环境变量写入Path中,如果在cmd下运行 gcc -v 有效果,表明安装好了

其次:

  • 下载boost库,http://www.boost.org/ 然后解压,比如我的boost文件夹在D:/Develop/boost/boost_1_70_0下 cd过去然后

  • 命令行输入 bootstrap gcc 编译

  • 再输入 ./b2.exe 编译即可。

我是Clion编译器,在CMakelist中添加:

include_directories(D:/Develop/boost/boost_1_70_0)
link_directories(D:/Develop/boost/boost_1_70_0/stage/lib)

就可以使用boost库了

#include<iostream>
#include<boost/tuple/tuple.hpp>
int main()
{
    boost::tuple<int,std::string,double> tuple1(1,"hello world",1.2);
    auto t1 = tuple1.get<0>();
    auto t2 = tuple1.get<1>();
    std::cout<<t1<<t2<<std::endl;
}

相关文章

网友评论

    本文标题:boost在ubuntu16,windows10的安装

    本文链接:https://www.haomeiwen.com/subject/eesllctx.html