Undefined reference to pthread_create in Linux

后端 未结 14 2549
梦毁少年i
梦毁少年i 2020-11-22 03:18

I picked up the following demo off the web from https://computing.llnl.gov/tutorials/pthreads/

#include 
#include 
#define NU         


        
14条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 03:56

    I believe the proper way of adding pthread in CMake is with the following

    find_package (Threads REQUIRED)
    
    target_link_libraries(helloworld
        ${CMAKE_THREAD_LIBS_INIT}
    )
    

提交回复
热议问题