Hi everybody.
I need some tutorial/example of C++ multithreading without use of boost libraries.
I know the portability problems I can encounter, but I'm working only under Linux and I need a very simple example.
Can anyone suggest me something?
Thanks!
Look for POSIX threads.
BTW if you are using C++ ( not C ) boost will be much more friendly
Googleing a bit I saw that using POSIX threads in C++ is such a mess.
I experimented boost and indeed is quite simple (I suggest to read
http://antonym.org/2009/05/threading-with-boost---part-i-creating-threads.html)
I discovered something maybe useful to newbes: to compile something with gcc, using boost 1.42.0 and their thread support you must run:
g++ -I/your/path/to/include -L/your/path/to/lib -lboost_thread-mt -o someting something.cpp
With the latest version (1.46.1) instead, the flag is different and you need to launch gcc as follows:
g++ -I/your/path/to/include -L/your/path/to/lib -lboost_thread -o someting something.cpp
After compilation, if you have problem launching your executable because some library link is missing, type before launch of the executable:
export LD_LIBRARY_PATH=/path/to/your/lib
Hope this helps!
Last edited on