简体   繁体   English

实现Boost.thread

[英]Implementing Boost.thread

I am learning boost c++ and thus I was trying this piece of code which deals with boost threads 我正在学习Boost C ++,因此我正在尝试处理Boost线程的这段代码

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

void wait(int seconds)
{
    boost::this_thread::sleep_for(boost::chrono::seconds(seconds));
}

void thread()
{
    for(int i = 0; i < 5; i++)
    {
        wait(2);
        std::cout << i << std::endl;
    }
}

int main()
{
    boost::thread t(thread);
    t.join();

    return 0;
}

But when I compile this code on VS2008 I get the following errors: 但是,当我在VS2008上编译此代码时,出现以下错误:

LINK : fatal error LNK1104: cannot open file 'boost_thread-vc90-mt-1_58.lib'

What I understood is this error is due to configuration issues but I don't know how to get rid of it. 我了解到此错误是由于配置问题引起的,但我不知道如何消除它。 Can somebody help me in solving this error? 有人可以帮助我解决这个错误吗?

First of all you need to compile boost (if you didn't). 首先,您需要编译boost(如果没有)。

Secondly you need to properly add this library to project, look at this answer . 其次,您需要正确地将此库添加到项目中,看看这个答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM