Steve
Steve

Reputation: 6444

Why can't I create a thread in a Boost.Test test case?

I have defined the following very simple test case:

#define BOOST_TEST_MODULE thread_test_module
#include <boost/test/unit_test.hpp>
#include <thread>

void do_nothing() {}

BOOST_AUTO_TEST_CASE ( boost_thread_test )
{
    std::thread t(do_nothing);
    t.join();
}

When it runs, I get the following error:

unknown location(0): fatal error in "boost_thread_test": std::runtime_error: Operation not permitted

According to this post, it appears that this should work. Why not?

Upvotes: 2

Views: 819

Answers (1)

Steve
Steve

Reputation: 6444

The solution to this problem was to link with the pthread library, by adding -lpthread to my linker command line.

Upvotes: 6

Related Questions