0

简单的应用程序,刚刚学习设置我的升压环境......

程序编译,但我得到一个 libboost_thread-mgw44-mt-1_51.dll is missing 错误

在旁注中,我不得不将 thread1.stop() 更改为 t1.stop(),因为 boost 说 stop() 没有函数。

我有 dll,将 dll 放在与应用程序相同的文件夹中没有任何作用。

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

class Threadable
{
  public:

    void stop()
    {
        running = false;
    }

    int run()
    {
        running = true;
        while(running)
        {
            //Do Something Meaningful
        }
        return 0;
    }


  private:
    bool running;
};

int main()
{
  Threadable t1, t2;
  boost::thread thread1(boost::bind(&Threadable::run, t1));
  boost::thread thread2(boost::bind(&Threadable::run, t2));

  // Let the threads run for half a second
  boost::this_thread::sleep(boost::posix_time::milliseconds(500));

  // Signal them to stop

  t1.stop();
  t2.stop();
  //thread1.stop();
  //thread2.stop();

  // Wait for them to gracefully exit
  thread1.join();
  thread2.join();
  return 0;
}
4

0 回答 0