CMake解决c++11的phread库问题:undefined reference to `pthread_create’
2021-01-03 01:29
标签:exec cmak ble std 解决 creat create sts dir 从cmake的CMakeLists.txt文件中可以看出cmake是像g++使用c++11特性一样,都有-std=c++11,所以像一样加个-pthread解决就行。 使用包Threads和链接${CMAKE_THREAD_LIBS_INIT} CMake解决c++11的phread库问题:undefined reference to `pthread_create’ 标签:exec cmak ble std 解决 creat create sts dir 原文地址:https://www.cnblogs.com/long5683/p/12992658.html方法一
PROJECT(HELLO)
set(CMAKE_CXX_FLAGS "${CAMKE_CXX_FLAGS} -std=c++11")
AUX_SOURCE_DIRECTORY(. SRC_LIST)
ADD_EXECUTABLE(hello ${SRC_LIST})
PROJECT(HELLO)
set(CMAKE_CXX_FLAGS "${CAMKE_CXX_FLAGS} -std=c++11 -pthread")
AUX_SOURCE_DIRECTORY(. SRC_LIST)
ADD_EXECUTABLE(hello ${SRC_LIST})
方法二
PROJECT(HELLO)
set(CMAKE_CXX_FLAGS "${CAMKE_CXX_FLAGS} -std=c++11")
FIND_PACKAGE(Threads)
AUX_SOURCE_DIRECTORY(. SRC_LIST)
ADD_EXECUTABLE(hello ${SRC_LIST})
TARGET_LINK_LIBRARIES(hello ${CMAKE_THREAD_LIBS_INIT})
下一篇:python分段计费demo
文章标题:CMake解决c++11的phread库问题:undefined reference to `pthread_create’
文章链接:http://soscw.com/index.php/essay/39711.html