Boost logo

Boost Users :

From: 御風只配做笨木頭 (jeffhung_at_[hidden])
Date: 2002-02-04 03:02:28


I cannot compile the thread example listed on the document:

I'm using g++ 2.95.3 on a FreeBSD 4.x box. Here are the exact
environment and compile error messages:

% uname -a
FreeBSD 4.5-PRERELEASE FreeBSD 4.5-PRERELEASE #0: Tue Jan 8 03:14:40 CST 2002 i386

% g++ -v
Using builtin specs.
gcc version 2.95.3 20010315 (release) [FreeBSD]

% cat test_thread0.cpp
#include <boost/thread/xtime.hpp>
#include <boost/thread/thread.hpp>
#include <iostream>

struct thread_alarm
   thread_alarm(int secs) : m_secs(secs) { }
   void operator()()
       boost::xtime xt;
       boost::xtime_get(&xt, ::boost::TIME_UTC);
       xt.sec += m_secs;


       std::cout << "alarm sounded..." << std::endl;

   int m_secs;

void run()
   int secs = 5;
   std::cout << "setting alarm for 5 seconds..." << std::endl;
   boost::thread thrd(thread_alarm(secs));
   std::cout << "main()" << std::endl;

int main()

% g++ -I/usr/local/include test_thread0.cpp
test_thread0.cpp: In function `void run()':
test_thread0.cpp:28: request for member `join' in `thrd', which is of non-aggregate type `boost::thread ()(thread_alarm)'

The boost library is installed through FreeBSD's ports collection which the boost version is 1.26.0.

I've tried to figure out where the problem is and failed to find the definition of class thread. Do I miss something? Or, is it just a freebsd porting problem?

ps. The example seems lack of a xtime inclution. So I add the #include at the first line:
#include <boost/thread/xtime.hpp>

Chien-Chou Hung / Jeff Hung / 洪健洲 (Big5)
National Chiao Tung University
Institute of Information Management

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at