Boost logo

Boost Users :

Subject: Re: [Boost-users] asio async_accept
From: Etienne Philip Pretorius (icewolfhunter_at_[hidden])
Date: 2008-09-30 17:20:00


Sorry to rehash an old thread,

I must be only person that just can not get this to work....

here is my build output:

/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/etienne/NetBeansProjects/mingle'
mkdir -p build/Debug/GNU-Linux-x86
g++ -c -g -o build/Debug/GNU-Linux-x86/main.o main.cc
mkdir -p build/Debug/GNU-Linux-x86
g++ -c -g -o build/Debug/GNU-Linux-x86/server.o server.cc
mkdir -p build/Debug/GNU-Linux-x86
g++ -c -g -o build/Debug/GNU-Linux-x86/client.o client.cc
mkdir -p dist/Debug/GNU-Linux-x86
g++ -o dist/Debug/GNU-Linux-x86/mingle
build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/server.o
build/Debug/GNU-Linux-x86/client.o -lpthread
build/Debug/GNU-Linux-x86/server.o: In function `mingle::server::accept()':
/home/etienne/NetBeansProjects/mingle/server.cc:36: undefined reference
to `mingle::server::handle_accept(mingle::client*, asio::error_code const&)'
collect2: ld returned 1 exit status
make[1]: *** [dist/Debug/GNU-Linux-x86/mingle] Error 1
make[1]: Leaving directory `/home/etienne/NetBeansProjects/mingle'
make: *** [.build-impl] Error 2

Build failed. Exit value 2.

Here is the code that complains:

void server::accept(
){

     client* connection = new client(
             acceptor_.io_service());
     client_.push_back(connection);
     acceptor_.async_accept(connection->socket(),
             boost::bind(&mingle::server::handle_accept,
             this,connection,asio::placeholders::error));

};//accept

void handle_accept(
     client* connection,
     const asio::error_code& ec
) {

};//handle_accept

The header file:

namespace mingle {
     class server {
     public:
         server(
             asio::io_service&,
             short
         );
         ~server() throw();
     private:
         void accept();
         void handle_accept(
             client*,
             const asio::error_code&
         );
         std::vector<client*> client_;
         asio::ip::tcp::acceptor acceptor_;
     protected:
     };
};

Now why would the linker of all things complain that it just can not
find the handle_accept method?

I modeled it after the online examples with one adjustment - the client
is not a Meyer's singleton like class.

Packaged information:

Package: libasio-dev
Priority: optional
Section: universe/devel
Installed-Size: 1404
Maintainer: Ubuntu MOTU Developers <ubuntu-motu_at_[hidden]>
Original-Maintainer: Simon Richter <sjr_at_[hidden]>
Architecture: all
Source: asio
Version: 0.3.8~rc3-2
Depends: libboost-dev
Recommends: libssl-dev
Filename: pool/universe/a/asio/libasio-dev_0.3.8~rc3-2_all.deb
Size: 149402
MD5sum: fe9a5519552f5d2703238e18c85a5acb
SHA1: 09fc70379b840dbba1654544b9299d11c39a6edb
SHA256: 38d69bbb72ea825c8be711e407b56bc871d97d6b29693ede3a6ac05f55edc925
Description: cross-platform C++ library for network programming
  asio is a cross-platform C++ library for network programming that provides
  developers with a consistent asynchronous I/O model using a modern C++
  approach. It has recently been accepted into Boost.
  .
  This package contains the development header files.
Bugs: mailto:ubuntu-users_at_[hidden]
Origin: Ubuntu

Thank you,
Etienne Pretorius


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net