参见安装编译:http://blog.csdn.net/xinqingwuji/article/details/51728725
博主的库目录为E:\boost_1_61_0\stage\lib,头文件目录为E:\boost_1_61_0
测试时包含#include <boost\thread.hpp>后,编译提示fatal error LNK1104: 无法打开文件“libboost_thread-vc90-mt-gd-1_61.lib”
原因是,博主编译的都是动态库。而boost的auto-link机制将会自动帮我们包含对应的静态lib,也就是说,boost默认是以静态方式链接的,
所以加上动态链接宏定义#define BOOST_ALL_DYN_LINK,或者在项目属性里加入。
关于boost的auto-link机制,详见boost\config\auto_link.hpp里的代码。
#include "iostream"
using namespace std;
#define BOOST_ALL_DYN_LINK
#include "boost/thread.hpp"
void threadFunc()
{
cout<<"thread hello world!"<<endl;
}
void main()
{
boost::function<void()> tdfunc(threadFunc);
boost::thread td(tdfunc);
td.join();
}
把exe与库放在一起执行。当然如果使用静态库会更简单一点,执行只需要exe。或者把库的目录设置成环境变量