/tmp/ccFjlkVB.o: In function `hello()':
test2.cpp:(.text+0xfe): undefined reference to `_ZSt4lockISt5mutexS0_IEEvRT_RT0_DpRT1_'
collect2: ld returned 1 exit status
Everything works fine without std::lock (for example using std::lock_guard or simply m.lock(); m2.lock(), but the point of using std::lock is chance to avoid potential deadlock).