tsuna / boost.m4

M4 macros to use Boost with the autotools
http://wiki.github.com/tsuna/boost.m4/
GNU General Public License v3.0
87 stars 52 forks source link

Need -pthread on some platforms if using an asio tcp_resolver #99

Open mschout opened 7 years ago

mschout commented 7 years ago

I have found out the hard way that the following code:

boost::asio::io_service io_service; boost::asio::ip::tcp::resolver r(io_service);

will not link unless the -pthread flag is given on some platforms (at least FreeBSD and CentOS 7).

I am working around this with the following addition to boost.m4:

BOOST_ASIO_RESOLVER()

---------------------

tcp resolver requires the pthread flag for linking

BOOST_DEFUN([Asio_Resolver], [AC_REQUIRE([_BOOST_PTHREAD_FLAG]) AC_SUBST([BOOST_ASIO_RESOLVER_LIBS], [$boost_cv_pthread_flag]) ])

This allows me to set LDFLAGS (or libs) for programs that are using the resolver so they link correctly. Not sure if there is a better way to do this, but it solves the problem for me.