Ubuntu使用多线程cmake时出现undefined reference to `pthread_create'

原因是ubuntu需要查找Threads第三方库,不能直接使用,因此,在cmakelists.txt文件中添加以下两行代码就ok

find_package(Threads)
target_link_libraries(HELLO ${CMAKE_THREAD_LIBS_INIT})
 

猜你喜欢

转载自www.cnblogs.com/excellentlhw/p/10806778.html