成都创新互联网站制作重庆分公司

【C++网络编程—linux下boost库源码编译安装】-创新互联

  • 先把Linux系统下的boost源码包boost_1_69_0.tar.gz拷贝到某一指定路径下,然后解压,如下:
root@iZ2ze4aqfcvyxgcvpjrj6iZ:~/software_installation$ ls
boost_1_69_0.tar.gz
root@iZ2ze4aqfcvyxgcvpjrj6iZ:~/software_installation$ tar -zxvf boost_1_69_0.tar.gz
  • tar解压完成后,进入源码文件目录,查看内容:
root@iZ2ze4aqfcvyxgcvpjrj6iZ:~/software_installation$ ls
boost_1_69_0  boost_1_69_0.tar.gz
root@iZ2ze4aqfcvyxgcvpjrj6iZ:~/software_installation cd boost_1_69_0/
root@iZ2ze4aqfcvyxgcvpjrj6iZ:~/software_installation/boost_1_69_0$ ls
boost            boostcpp.jam  boost.png      bootstrap.sh  index.htm   INSTALL  libs             more     status
boost-build.jam  boost.css     bootstrap.bat  doc           index.html  Jamroot  LICENSE_1_0.txt  rst.css  tools
  • 运行bootstrap.sh工程编译构建程序,查看目录:
root@iZ2ze4aqfcvyxgcvpjrj6iZ:~/software_installation/boost_1_69_0$ ./bootstrap.sh 
Building Boost.Build engine with toolset gcc... tools/build/src/engine/bin.linuxx86_64/b2
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/build/doc/html/index.html

root@iZ2ze4aqfcvyxgcvpjrj6iZ:~/software_installation/boost_1_69_0$ ls
b2     boost-build.jam  boost.png      bootstrap.sh  index.html  libs             project-config.jam  tools
bjam   boostcpp.jam     bootstrap.bat  doc           INSTALL     LICENSE_1_0.txt  rst.css
boost  boost.css        bootstrap.log  index.htm     Jamroot     more             status
  • 运行b2程序
root@iZ2ze4aqfcvyxgcvpjrj6iZ:~/software_installation/boost_1_69_0$ ./b2

编译完成后,会有如下打印:

成都创新互联主营靖安网站建设的网络公司,主营网站建设方案,成都APP应用开发,靖安h5小程序定制开发搭建,靖安网站营销推广欢迎靖安等地区企业咨询
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
/home/tony/package/boost_1_69_0
The following directory should be added to linker library paths:
/home/tony/package/boost_1_69_0/stage/lib
root@iZ2ze4aqfcvyxgcvpjrj6iZ:~/software_installation# ./b2 install

安装完成后,最后会有如下信息打印出来:

ln-UNIX /usr/local/lib/libboost_wave.so
common.copy /usr/local/lib/libboost_exception.a
common.copy /usr/local/lib/libboost_system.a
common.copy /usr/local/lib/libboost_chrono.a
common.copy /usr/local/lib/libboost_timer.a
common.copy /usr/local/lib/libboost_test_exec_monitor.a
...updated 14831 targets...
  • 验证安装boost是否成功

test.cpp

#include#include#includeusing namespace std;

class Hello
{public:
	void say(string name) 
	{cout<< name<< " say: hello world!"<< endl; }
};

int main()
{Hello h;
	auto func = boost::bind(&Hello::say, &h, "小呆鸟");
	func();
	return 0;
}

执行命令

g++ -o test test.cpp -std=c++11
./test

'结果显示'
小呆鸟 say: hello world!

你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧


网站题目:【C++网络编程—linux下boost库源码编译安装】-创新互联
地址分享:http://cxhlcq.com/article/hoope.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部