bjam使用例子

下载完整的bjam使用例子:http://download.csdn.net/detail/dotphoenix/9626088


目录结构:

bjam_example

    ----Jamroot

    ----src 

        ----Jamfile

        ---- main.cpp

    ----lib_src

        ----hello.cpp

        ---- weather.cpp

        ----Jamfile

    ----inc

        ----lib.h


Jamroot的内容:

project : requirements <include>"./inc" ;
build-project src ;
src/Jamfile的内容:

<span style="font-family:SimSun;font-size:18px;">exe main : main.cpp boost_thread boost_system ../lib_src//functions ; # 冒號和分號都要記得留空白唷
lib boost_thread : : <name>boost_thread <search>"../../../lib" ;
lib boost_system : : <name>boost_system <search>"../../../lib" ;</span>

src/main.cpp的内容:

<span style="font-family:SimSun;font-size:18px;">#include "lib.h"

int main(int argc, char* argv[])
{
	start_hello();
	start_weather();
	wait_hello();
	wait_weather();
    return 0;
}
</span>

inc/lib.h的内容:

<span style="font-family:SimSun;font-size:18px;">void start_hello();
void wait_hello();
void start_weather();
void wait_weather();
</span>

lib_src/Jamfile的内容:

<span style="font-family:SimSun;font-size:18px;">lib functions : hello.cpp weather.cpp : <link>static : : <include>"../../../include" ; # 冒號和分號都要記得留空白唷</span>

lib_src/hello.cpp的内容:

<span style="font-family:SimSun;font-size:18px;">#include <iostream>
#include <boost/thread.hpp>

static void fun()
{
	int i = 0;
	while(i++ < 8)
	{
		std::cout<<"Hello world!"<< std::endl;
		boost::this_thread::sleep(boost::posix_time::seconds(1));
	}
}
static boost::thread* thrd;
void start_hello()
{
	    
     thrd = new boost::thread(&fun);
}
void wait_hello()
{
	thrd->join();
	delete thrd;
}</span>


lib_src/weather.cpp的内容:

<span style="font-family:SimSun;font-size:18px;">#include <iostream>
#include <boost/thread.hpp>

static void fun()
{
	int i = 0;
	while(i++ < 8)
	{
		std::cout<<"The weather is sunny!"<< std::endl;
		boost::this_thread::sleep(boost::posix_time::seconds(1));
	}
}

static boost::thread* thrd;
void start_weather()
{
	    
     thrd = new boost::thread(&fun);
}
void wait_weather()
{
	thrd->join();
	delete thrd;
}</span>

然后执行:

../../boost_1_54_0/bjam 


PS:

以Jamroot为根目录

bjam所在的位置为../../boost_1_54_0/ 

boost libraries所在的位置为../../lib

boost headers所在的位置为../../include

需要在.bashrc里面设置如下路径:

BOOST_BUILD_TOOLS_PATH=/home/azhu/sourcecode/boost/boost_1_54_0/tools/build/v2/
export BOOST_BUILD_TOOLS_PATH



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值