c++ - 未找到 Windows7 pthread.h

标签 c++ windows cmake pthreads

我正在尝试使用 cmake 在 Windows 中编译 libaws (http://sourceforge.net/projects/libaws/) 库。我已经包含了 openssl、libxml、libcurl,并且我正在使用这个命令行。

C:\libaws>cmake -G "Visual Studio 10" -DCURL_LIBRARY="C:\tools\curl-7.28.1\lib" -DCURL_INCLUDE_DIR="C:\tools\curl-7.28.1\include" -DLIBXML2_LIBRARIES="C:\tools\libxml22.7.8.win32\lib" -DLIBXML2_INCLUDE_DIR="C:\tools\libxml2-2.7.8.win32\include" -DPTHREAD_INCLUDE_DIR="C:\tools\pthread\include"  ..\tools\libaws-0.9.2
--    

它抛出以下错误:

-- Check for working C compiler using: Visual Studio 10
-- Check for working C compiler using: Visual Studio 10 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 10
-- Check for working CXX compiler using: Visual Studio 10 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found CURL: C:/tools/curl-7.28.1/lib (found version "7.28.1")
-- Found OpenSSL: optimized;C:/openssl/lib/ssleay32.lib;debug;C:/openssl/lib/ssleay32.lib;optimized;C:/openssl/lib/libeay32.lib;debug;C:/openssl/lib/libeay32.lib (found version "1.0.1c")
-- Found LibXml2: C:/tools/libxml2-2.7.8.win32/lib (found version "2.7.8")
-- Looking for include file pthread.h
-- Looking for include file pthread.h - not found.

CMakeLists.txt:78 处的 CMake 错误(消息): 找不到 pthread 开发 header

我在 C:\tools\pthread\include 中包含了 ptherad.h、semaphore.h 等,并将其作为命令行标志提供:-DPTHREAD_INCLUDE_DIR="C:\tools\pthread\include"。在我的 CMakeLists.txt 中,我添加了

INCLUDE_DIRECTORIES(${PTHREAD_INCLUDE_DIR})

有什么想法吗?

最佳答案

Visual Studio 没有附带“pthread”实现。我想您需要使用其他编译器,例如 MinGW。

@jens-a-koch 是对的:我的回答不应该被接受!请“不接受”,以便我将其删除。

我相信您的 CMake 查找模块可能没有使用 PTHREAD_INCLUDE_DIR 定义(类似于@ drescherjm 所说的)。

关于c++ - 未找到 Windows7 pthread.h,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13485613/

相关文章:

c++ - 什么时候用简单的话用extern "C"?

c++ - iostream vs ostream 有什么不同?

windows - 如何在 Windows 中使用 Putty 从远程服务器复制文件?

cmake - 遇到CMake错误:无法为非项目创建的目标指定链接库

c++ - 如何更改使用CPack安装的可执行文件的名称?

c++ - 如何为派生类传播 friend

python - Python 中的 C++ 库 : custom sorting method

windows - 设置 EXE 版本信息

android - 为什么在Windows下为Android 2.3设置开发环境如此噩梦?

api - 在 cmake 中使用包括相邻子项目