Open Side Menu Go to the Top
Register
C++ Threading w/ Boost Library C++ Threading w/ Boost Library

03-06-2017 , 11:54 AM
Quote:
Originally Posted by goofyballer
As someone who just arrived on the "modern C++" scene a couple years ago, lots of Boost stuff (including threads) seems to me like it's been assimilated into or superseded by C++11.
Yeah, really the C++ language was lacking very basic obviously needed features for *years* and boost implemented a bunch of them. The good ones got folded into the C++ standard, and Boost is sort of seen as a proving ground for new features.

I try not to use Boost features, because it really just complicates things needlessly, in terms of compiling and distributing. I try not to use too many libraries at all unless they are really needed and/or widely available.
C++ Threading w/ Boost Library Quote
03-06-2017 , 01:01 PM
Quick question, how do you know what to link to?

Code:
#include <boost/interprocess/managed_shared_memory.hpp>
#include <cstdlib> //std::system
#include <sstream>
And, I should be linking to what?

Also, just getting back into C++, didn't realize that much of it is adopted in newer versions.

Interesting, just noticed that when I did the re-install I did not do the step

Code:
./b2 install
Putting all the files in /usr/local/lib

Now that the files are there, it does not work. But, when the files are not there it does work!

Last edited by leavesofliberty; 03-06-2017 at 01:21 PM.
C++ Threading w/ Boost Library Quote
03-06-2017 , 02:03 PM
Did an example with chrono.cpp from this link. https://theboostcpplibraries.com/boost.chrono

I think specifically there's a bug in the sleep_for function that happens only when using the linked package.
C++ Threading w/ Boost Library Quote
03-06-2017 , 04:48 PM
You might already have boost installed somewhere else in the system, because it's available as packages from debian etc. In fact, unless you have a specific version to compile it yourself it's probably better to use the official packages for your distro.

How do you know which libraries to link to? Mostly experience. There are some tools you can use depending on your OS. There's a tool called "nm" for example that can be used to dump the symbols in a library. When you go to link and it complains that it can't find a symbol, you can, for example, run nm on all the boost libraries and grep for that symbol. This doesn't always work.
C++ Threading w/ Boost Library Quote
03-06-2017 , 06:14 PM
Quote:
Originally Posted by RustyBrooks
You might already have boost installed somewhere else in the system, because it's available as packages from debian etc. In fact, unless you have a specific version to compile it yourself it's probably better to use the official packages for your distro.

How do you know which libraries to link to? Mostly experience. There are some tools you can use depending on your OS. There's a tool called "nm" for example that can be used to dump the symbols in a library. When you go to link and it complains that it can't find a symbol, you can, for example, run nm on all the boost libraries and grep for that symbol. This doesn't always work.
Thanks for your post. I had conflicting installations, different versions, so I had to purge them both, and re-install from source, and also do one command

1. Find the version.

Code:
dpkg -S /usr/include/boost/version.hpp
2. Purge it.

Code:
apt-get remove libboost1.XX-dev
3. Clean the directories.

Code:
rm -r /usr/local/lib/libboost*
4. Deconfig magic.

Code:
ldconfig
5. Re-install from binaries

Code:
tl'dr
after perusing StackOverflow, and it works! Boost is probably a waste of time with C++v11 out. BUT, not going to pick a fight I can't finish.
C++ Threading w/ Boost Library Quote
03-08-2017 , 02:45 AM
Ya my code at work includes a whole pile of stuff written years ago that uses boost, most of which could now use the std:: versions.

boost is a lot less necessary now, there are still some useful libraries (we use Asio for example) but generally look to the std library first for stuff and only use boost if it's not there (or if you're in the unfortunate position of having to maintain old code that uses a lot of boost :P)

Last edited by DarkMagus; 03-08-2017 at 02:53 AM.
C++ Threading w/ Boost Library Quote
03-08-2017 , 12:57 PM
Quote:
Originally Posted by DarkMagus
Ya my code at work includes a whole pile of stuff written years ago that uses boost, most of which could now use the std:: versions.

boost is a lot less necessary now, there are still some useful libraries (we use Asio for example) but generally look to the std library first for stuff and only use boost if it's not there (or if you're in the unfortunate position of having to maintain old code that uses a lot of boost :P)
I've decided not to use Boost, except when absolutely necessary, probably when I get to where I need Asio. Thanks goofyballer, RustyBrooks, et. al.
C++ Threading w/ Boost Library Quote
03-14-2017 , 10:48 AM
Why not just use pthread? Comes with any sort of linux.
Google "yolinux posix thread" for a really good tutorial on multi-threading.
C++ Threading w/ Boost Library Quote
05-19-2017 , 09:37 AM
Quote:
Originally Posted by Xsaa
Why not just use pthread? Comes with any sort of linux.
Google "yolinux posix thread" for a really good tutorial on multi-threading.
Thanks, I will look into it. So far I am using straight C.
C++ Threading w/ Boost Library Quote
05-19-2017 , 04:30 PM
Quote:
Originally Posted by leavesofliberty
Thanks, I will look into it. So far I am using straight C.
C 11 and C++ 11 have a concurrency model now. Easier to code and probably more portable than pthreads. Nothing wrong with learning pthreads though.

Stack Overflow link on C 11 and C++ 11 concurrency.
C++ Threading w/ Boost Library Quote
05-20-2017 , 01:35 PM
Quote:
Originally Posted by adios
C 11 and C++ 11 have a concurrency model now. Easier to code and probably more portable than pthreads. Nothing wrong with learning pthreads though.

Stack Overflow link on C 11 and C++ 11 concurrency.
Many thanks. Definately getting up to spead. Working on AI and multiplayer games so have to learn everything I can about modern threading techniques first and network programming.
C++ Threading w/ Boost Library Quote
05-20-2017 , 01:51 PM
Quote:
Originally Posted by leavesofliberty
Many thanks. Definately getting up to spead. Working on AI and multiplayer games so have to learn everything I can about modern threading techniques first and network programming.
C++ Concurrency in Action

This is a good book on the topic. If you search around enough on the webs you can find a PDF version and that with a Kindle will get you the book for free.

I would also recommend Herb Sutter's articles on concurrency. These are more about how to design code to tackle problems where concurrency is needed.
C++ Threading w/ Boost Library Quote
05-20-2017 , 02:09 PM
Thanks, ordered it on Amazon. Paper is easier on the eyes.
C++ Threading w/ Boost Library Quote

      
m