thanks, 

But, this time,  I got strange errors : 
I cannot find where my code is wrong. 

Any help is really appreciated. 

/tmp/ccnnkCEQ.o: In function `thread_data_base':
/boost_1_45_0v/include/boost/thread/pthread/thread_data.hpp:67: undefined reference to `vtable for boost::detail::thread_data_base'
/tmp/ccnnkCEQ.o: In function `interruption_checker':
/boost_1_45_0v/include/boost/thread/pthread/thread_data.hpp:97: undefined reference to `boost::detail::get_current_thread_data()'
/tmp/ccnnkCEQ.o: In function `boost::condition_variable::wait(boost::unique_lock<boost::mutex>&)':
/boost_1_45_0v/include/boost/thread/pthread/condition_variable.hpp:55: undefined reference to `boost::this_thread::interruption_point()'
/tmp/ccnnkCEQ.o: In function `boost::shared_mutex::lock()':
/boost_1_45_0v/include/boost/thread/pthread/shared_mutex.hpp:129: undefined reference to `boost::this_thread::disable_interruption::disable_interruption()'
/boost_1_45_0v/include/boost/thread/pthread/shared_mutex.hpp:137: undefined reference to `boost::this_thread::disable_interruption::~disable_interruption()'
/boost_1_45_0v/include/boost/thread/pthread/shared_mutex.hpp:137: undefined reference to `boost::this_thread::disable_interruption::~disable_interruption()'
/tmp/ccnnkCEQ.o: In function `boost::shared_mutex::lock_shared()':
/boost_1_45_0v/include/boost/thread/pthread/shared_mutex.hpp:59: undefined reference to `boost::this_thread::disable_interruption::disable_interruption()'
/boost_1_45_0v/include/boost/thread/pthread/shared_mutex.hpp:66: undefined reference to `boost::this_thread::disable_interruption::~disable_interruption()'
/boost_1_45_0v/include/boost/thread/pthread/shared_mutex.hpp:66: undefined reference to `boost::this_thread::disable_interruption::~disable_interruption()'
/tmp/ccnnkCEQ.o: In function `~thread_data':
/boost_1_45_0v/include/boost/thread/detail/thread.hpp:42: undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
/boost_1_45_0v/include/boost/thread/detail/thread.hpp:42: undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
/tmp/ccnnkCEQ.o: In function `thread<boost::_bi::bind_t<void, boost::_mfi::mf0<void, lab1::Server>, boost::_bi::list1<boost::_bi::value<lab1::Server*> > > >':
/boost_1_45_0v/include/boost/thread/detail/thread.hpp:204: undefined reference to `boost::thread::start_thread()'
/tmp/ccnnkCEQ.o: In function `~auto_ptr':
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/memory:259: undefined reference to `boost::thread::~thread()'
/tmp/ccnnkCEQ.o: In function `~thread_group':
/boost_1_45_0v/include/boost/thread/detail/thread_group.hpp:34: undefined reference to `boost::thread::~thread()'
/tmp/ccnnkCEQ.o: In function `boost::thread_group::join_all()':
/boost_1_45_0v/include/boost/thread/detail/thread_group.hpp:74: undefined reference to `boost::thread::join()'
/tmp/ccnnkCEQ.o:(.rodata._ZTIN5boost6detail11thread_dataINS_3_bi6bind_tIvNS_4_mfi3mf0IvN4lab16ServerEEENS2_5list1INS2_5valueIPS7_EEEEEEEE[typeinfo for boost::detail::thread_data<boost::_bi::bind_t<void, boost::_mfi::mf0<void, lab1::Server>, boost::_bi::list1<boost::_bi::value<lab1::Server*> > > >]+0x10): undefined reference to `typeinfo for boost::detail::thread_data_base'
collect2: ld returned 1 exit status
make: *** [lab2_server] Error 1




Date: Tue, 6 Sep 2011 02:50:50 +0400
From: i.nixman@gmail.com
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] boost bind() error for creating thread

threadGroup.create_thread(boost::bind(&lab1::Server::Run, &server));

2011/9/6 Jack Bryan <dtustudy68@hotmail.com>
Hi,

I using boost::bind() to create thread. But, I got errors at:

threadGroup.create_thread(boost::bind(&lab1::Server::Run, server));

Any help is really appreciated. 

Code is as follows: 
---------------------------------------------

class Server {
public:
  // The constructor takes a port number and prepares to receive HTTP
  // requests from clients on that port.
  explicit Server(int port);

  // Closes the connection.
  ~Server();

  // 
  void Run();
  //Server(Server&);
private:
  // 'listening' socket used to establish HTTP connections
  int listen_fd_;

  // Non-copyable, non-assignable
  Server(Server&);
  Server& operator=(Server&);
}; 


int main(int argc, char *argv[]) {
  if (argc != 2) {
    std::cout << "Usage: lab1 <port>" << std::endl;
    return 1;
  }

// Convert the port from a string to an integer.
  int port_number;
  std::istringstream port_stream(argv[1]); // argv[1] is port number, 
  port_stream >> port_number;

  // Convert the thread number from a string to an integer.
  int thread_number;
  std::istringstream thread_stream(argv[2]); // argv[1] is port number, 
  thread_stream >> thread_number;
  lab1::Server server(port_number);

boost::thread_group threadGroup;

for(int i=0;i<thread_number;i++)
  {

     threadGroup.create_thread(boost::bind(&lab1::Server::Run, server));
  }
threadGroup.join_all();
  
  
  return 0;
}

error: no matching function for call to âboost::_bi::bind_t<void, boost::_mfi::mf0<void, lab1::Server>, boost::_bi::list1<boost::_bi::value<lab1::Server> > >::bind_t(boost::_bi::bind_t<void, boost::_mfi::mf0<void, lab1::Server>, boost::_bi::list1<boost::_bi::value<lab1::Server> > >)â


/bind.hpp:865: note: candidates are: boost::_bi::bind_t<void, boost::_mfi::mf0<void, lab1::Server>, boost::_bi::list1<boost::_bi::value<lab1::Server> > >::bind_t(boost::_bi::bind_t<void, boost::_mfi::mf0<void, lab1::Server>, boost::_bi::list1<boost::_bi::value<lab1::Server> > >&)

lab2.cpp:241: error:   initializing argument 1 of âboost::thread* boost::thread_group::create_thread(F) [with F = boost::_bi::bind_t<void, boost::_mfi::mf0<void, lab1::Server>, boost::_bi::list1<boost::_bi::value<lab1::Server> > >]â


bind_mf_cc.hpp: In function âboost::_bi::bind_t<R, boost::_mfi::mf0<R, T>, typename boost::_bi::list_av_1<A1>::type> boost::bind(R (T::*)(), A1) [with R = void, T = lab1::Server, A1 = lab1::Server]â

error:   initializing argument 1 of âboost::thread* boost::thread_group::create_thread(F) [with F = boost::_bi::bind_t<void, boost::_mfi::mf0<void, lab1::Server>, boost::_bi::list1<boost::_bi::value<lab1::Server> > >]â

instantiated from here
bind_mf_cc.hpp:24: error: no matching function for call to âboost::_bi::list1<boost::_bi::value<lab1::Server> >::list1(boost::_bi::list1<boost::_bi::value<lab1::Server> >)â




_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users