Open mschout opened 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_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.
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.