 <p>Your first problem is that <code>-lpthread</code> is a linker option, so it belongs on the linker line (the second command) rather than the compilation line. (Note that the order of the parameters can matter; I got it to work by putting <code>-lpthread</code> on <strong>last</strong>. I also tried using <code>-pthread</code> instead of <code>-lpthread</code>, which did appear to work and was also less sensitive to where it was put on the linker line. But again, it's a <em>linker</em> option, not a <em>compile</em> option.)</p> <p>After fixing that, I was able to get your program to compile and run, but it exited with a different exception: <code>terminate called without an active exception</code>. To fix this problem, call <code>thread_fct.join();</code> in <code>main()</code>. (All threads must be joined, detached, or moved-from before they go out of scope, or your program will abort.)</p>