Skip to content

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

@mschout

Description

@mschout

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions