|
Boost Users : |
Subject: Re: [Boost-users] Workaround for g++ problem compiling Boost.Asio examples on Ubuntu 8.04.3
From: Andrew Maclean (andrew.amaclean_at_[hidden])
Date: 2009-12-10 23:05:18
That is a very old version of boost. I just just download the source
and build and install the latest version. If you do this, a lot of
your problems will disappear.
Andrew
On Thu, Dec 10, 2009 at 2:35 PM, David Featherstone
<dfeathers_at_[hidden]> wrote:
>
> I'm running Ubuntu 8.04.3 as a VMware virtual machine hosted by Windows XP on
> a Lenovo T61 laptop.
>
> Synaptic Package Manager [or apt-get] on Ubuntu 8.04.3 offers both the
> libboost-dev v1.34.1 and the libasio-dev v0.3.8 packages with pre-built
> libraries. Version 1.34 of Boost does not have an integrated asio library;
> asio integration appears in v1.35 and later versions of Boost.
>
> Source code for the problematic example program can be found here:
> http://www.boost.org/doc/libs/1_41_0/doc/html/boost_asio/tutorial/tuttimer4/src.html
> Source listing for Timer.4
>
> The first compile problem occurs at the second #include:
>
> #include <boost/asio.hpp>
>
> The compiler cannot find this header because asio.hpp was installed under
> /usr/include rather than under /usr/include/boost. I fixed this issue by
> creating a soft link to /usr/include/asio.hpp in /usr/include/boost:
>
> $ sudo ln -s ../asio.hpp /usr/include/boost/asio.hpp
>
> Solving the second compile problem proved more difficult. The second compile
> problem occurred at the first use of the boost::asio namespace:
>
> printer(boost::asio::io_service& io)
>
> Changing all occurrences of 'boost::asio' to simply 'asio' solves this
> problem, but makes tedium of playing with the examples and developing new
> code that will be compatible with v1.35+ of Boost. Instead, I employed
> namespace declarations to (artificially) nest the asio namespace within the
> boost namespace. This artificial nesting is straight-forward - a single line
> of code:
>
> #include <iostream>
> #include <boost/asio.hpp>
> #include <boost/bind.hpp>
> #include <boost/date_time/posix_time/posix_time.hpp>
>
> namespace boost { namespace asio { using namespace ::asio; } }
>
> class printer
> {
> public:
> printer(boost::asio::io_service& io)
> o o o
>
> Caution: I have not made exhaustive tests of this workaround, but it does
> compile [g++ 4.2.4] , link, and run on my platform:
>
> $ g++ -o timer timer.cpp -lboost_thread
> $ ./timer
> 0
> 1
> 2
> 3
> 4
> Final count is 5
>
> You may find more helpful information here, from the developer of the asio
> library:
> http://blog.think-async.com/ http://blog.think-async.com
> --
> View this message in context: http://old.nabble.com/Workaround-for-g%2B%2B-problem-compiling-Boost.Asio-examples-on-Ubuntu-8.04.3-tp26721653p26721653.html
> Sent from the Boost - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
-- ___________________________________________ Andrew J. P. Maclean Centre for Autonomous Systems The Rose Street Building J04 The University of Sydney 2006 NSW AUSTRALIA Ph: +61 2 9351 3283 Fax: +61 2 9351 7474 URL: http://www.acfr.usyd.edu.au/ ___________________________________________
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