实战经验:CentOS环境下搭建boost开发环境

实战经验:CentOS环境下搭建boost开发环境

作者:BlogUpdater |  时间:2018-04-17 |  浏览:3479 |  评论已关闭 条评论

boost库是十分强大的C++开源库,之前都是在Windows下的VS中集成使用。今天我们来看看如何在CentOS环境下搭建boost开发环境。

安装boost库

# yum install boost

# yum install boost-devel

新建一个最简单的helleworld,文件名命名为main.cpp,文件内容如下:

#include <boost/thread/thread.hpp>
#include <iostream>

using namespace std;

void NewThread()
{
        cout << "New thread is running..." << endl;
}

int main(int argc, char* argv[])
{
        boost::thread newthread(&NewThread);
        newthread.join();
        return 0;
}

代码编译
# g++ main.cpp -o test -lboost_system -lboost_thread

代码执行效果

至此,boost开发环境搭建完成,可以写一些基于boost库的Linux小程序了。

标签:

评论已关闭。