Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost.Thread Linking - boost_thread vs. boost_thread-mt

Tags:

It's not clear to me what linking options exist for the Boost.Thread 1.34.1 library. I'm on Ubuntu 8.04 and I've found that when using either boost_thread or boost_thread-mt during linking both compile and run, but I don't see any documentation on these or any other linking options in above link.

What Boost.Thread linking options are available and what do they mean?

like image 346
Robert S. Barnes Avatar asked Jun 13 '10 09:06

Robert S. Barnes


People also ask

What is boost thread library?

It provides classes and functions for managing the threads themselves, along with others for synchronizing data between the threads or providing separate copies of data specific to individual threads. The Boost.Thread library was originally written and designed by William E. Kempf (version 1).

Can I install boost threads using BoostPro?

A non-nonsense guide to setting up Boost threads in Visual Studio environments. Unfortunately BoostPro is no longer supported and no longer available, thereby obsoleting the part of this article that deals with installing Boost Threads using BoostPro.

How do I detach a thread from another thread in boost?

A thread is always bound to a variable of type boost::thread in the beginning, but once created, the thread no longer depends on that variable. There is even a member function called detach () that allows a variable of type boost::thread to be decoupled from its corresponding thread.

Can I use boost thread with Chrono?

Even though Boost.Chrono has been part of the standard library with C++11, types from std::chrono cannot be used with Boost.Thread. Doing so will lead to compiler errors. If you don’t want to call join () at the end of main (), you can use the class boost::scoped_thread. Example 44.2.


1 Answers

Well...

The first amusing thing is that the -mt modifier in the name is to indicate the library is Ok for multithreading. Which could lead us to believe that boost_thread (without this modifier) could be multithread-unsafe...

But the real thing is that (as seen on my own Ubuntu 10.04 box), boost_thread is a soft link to boost_thread-mt, which means the two are one and the same.

If you want to verify it, you can open a console on your ubuntu (make the console fullscreen because the names are long), then type:

cd /usr/lib 

to move to the directory where the Boost libraries are. And then:

ls -l ./libboost_thread* 

Which will list all the files starting with libboost_thread, with additionnal information. The result will be something like:

[...] ./libboost_thread.a [...] ./libboost_thread-mt.a -> libboost_thread.a 

As you can see, libboost_thread.a is a static library, and libboost_thread-mt.a is a soft link to libboost_thread.a

like image 100
paercebal Avatar answered Oct 25 '22 20:10

paercebal