【已解决】CMake undefined reference to `pthread_create’

原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: 【已解决】CMake undefined reference to `pthread_create’

cmake需要链接pthread库时,如果写法不当,会出现如下错误:

undefined reference to `pthread_create'

QQ截图20160831133629

正确的解决办法是:

cmake_minimum_required (VERSION 2.6) 
find_package (Threads)
add_executable (myapp main.cpp ...)
target_link_libraries (myapp ${CMAKE_THREAD_LIBS_INIT})

参考:http://stackoverflow.com/questions/1620918/cmake-and-libpthread

原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: 【已解决】CMake undefined reference to `pthread_create’

文章的脚注信息由WordPress的wp-posturl插件自动生成



|2|left
打赏

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: