you can use -u to solve the problem (test in gcc version 4.6.3 / (Ubuntu EGLIBC 2.15-0ubuntu10.4) 2.15, gcc version 4.8.1 / (Ubuntu EGLIBC 2.15-0ubuntu10.5 ~ ppa1) 2.15)
-Wl, -u, pthread_cancel, -u, pthread_cond_broadcast, -u, pthread_cond_destroy, -u, pthread_cond_signal, -u, pthread_cond_wait, -u, pthread_create, -u, pthread_dealach, -u, pthread_condalsign , pthread_join, -u, pthread_mutex_lock, -u, pthread_mutex_unlock, -u, pthread_once, -u, pthread_setcancelstate
1. reproduce the error
g++ -g -O0 -static -std=c++11 t.cpp -lpthread ./a.out terminate called after throwing an instance of 'std::system_error' what(): Enable multithreading to use std::thread: Operation not permitted Aborted (core dumped) nm a.out | egrep "\bpthread_.*" w pthread_cond_broadcast w pthread_cond_destroy w pthread_cond_signal w pthread_cond_wait w pthread_create w pthread_detach w pthread_equal w pthread_join w pthread_mutex_lock w pthread_mutex_unlock w pthread_once w pthread_setcancelstate
2. resolve the error
g++ -g -O0 -static -std=c++11 t.cpp -lpthread -Wl,-u,pthread_join,-u,pthread_equal ./a.out FOO BAR nm a.out | egrep "\bpthread_.*" 0000000000406320 T pthread_cancel w pthread_cond_broadcast w pthread_cond_destroy w pthread_cond_signal w pthread_cond_wait 0000000000404970 W pthread_create w pthread_detach 00000000004033e0 T pthread_equal 00000000004061a0 T pthread_getspecific 0000000000403270 T pthread_join 0000000000406100 T pthread_key_create 0000000000406160 T pthread_key_delete 00000000004057b0 T pthread_mutex_lock 00000000004059c0 T pthread_mutex_trylock 0000000000406020 T pthread_mutex_unlock 00000000004063b0 T pthread_once w pthread_setcancelstate 0000000000406220 T pthread_setspecific
Andy Jan 05 '15 at 6:58 2015-01-05 06:58
source share