undefined reference to `pthread_cancel'
问题 I have written the following T class with pthread . When i compile this class using g++ -lpthread then it's working fine. But if i extend this class from another class A and compile all together it's returns an error; "undefined reference to pthread_cancel" Code: class T{ private: pthread_t thread; public: void start(){ pthread_create(&thread,NULL,&run,this); } void destroy_thread(){ pthread_cancel(thread); } static void* run(void*){} ~Thread(){ destroy_thread(); } }; Next class: class A:T{ A