0

I am trying to compile libaws (http://sourceforge.net/projects/libaws/) library in Windows using cmake. I have included openssl, libxml, libcurl and I am using this command line.

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
--    

It throws the following error:

-- 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.

CMake Error at CMakeLists.txt:78 (MESSAGE): Could not find pthread development headers

I have included ptherad.h, semaphore.h etc. in C:\tools\pthread\include, and provided that as a command line flag: -DPTHREAD_INCLUDE_DIR="C:\tools\pthread\include". In my CMakeLists.txt, I added

INCLUDE_DIRECTORIES(${PTHREAD_INCLUDE_DIR})

Any ideas?

Jens A. Koch
  • 39,862
  • 13
  • 113
  • 141
Rajat
  • 1,766
  • 2
  • 21
  • 42
  • I don't know the answer, but I'm guessing the "P" in "P-Thread" might have something to do with it – user541686 Nov 21 '12 at 02:52
  • I didn't get you. Where are you referring this to? – Rajat Nov 21 '12 at 02:56
  • "P" stands for POSIX. Windows isn't a POSIX system, so it would make sense that most compilers wouldn't ship with POSIX-based APIs on Windows. – user541686 Nov 21 '12 at 03:31
  • I don't get it - you accepted an answer that indicates you don't have a `pthread.h`, but you clearly told the compiler (and us) that it was in `c:\tools\pthread\include` - did you just make that up? By the way, you can get a pthread implementation for Windows here: http://www.sourceware.org/pthreads-win32/ – Michael Burr Nov 21 '12 at 07:18
  • @Michael Burr Well, I also think your answer is better than mine :) – Pedro Boechat Nov 21 '12 at 19:37
  • 3
    I believe the problem is the CMake find module for threads assumes you are not using pthreads if you are using visual studio and that needs to be fixed to make this work. I remember someone asked a similar pthreads + cmake + Visual Studio question here 2 or so weeks ago. http://stackoverflow.com/questions/13218646/cmake-pthread-h-not-found-in-windows – drescherjm Nov 22 '12 at 06:45
  • it's a cmake bug, see https://stackoverflow.com/questions/24813827/cmake-failing-to-detect-pthreads-due-to-warnings/25130590#25130590 i got this problem on ubuntu – Jerry.CUi Dec 15 '17 at 06:07

2 Answers2

3

Visual Studio doesn't come with a "pthread" implementation. I guess you'll need to use another compiler, like MinGW.

@jens-a-koch is right: my answer should not be accepted! Please "unaccept" so I can remove it.

I belive that your CMake find module might not be using the PTHREAD_INCLUDE_DIR define (similarly to what@ drescherjm said).

Pedro Boechat
  • 2,446
  • 1
  • 20
  • 25
  • 1
    This shouldn't be the accepted answer. It's not about VisualStudio/VC or Mingw shipping an implementation of "pthread". The issue is that CMake doesn't detect pthread, when installed as an external dependency - even if the correct include path is set. – Jens A. Koch Jun 11 '16 at 13:27
0

I had the same error and the solution in short was to install Git for windows!

-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE

and in CMakeError

checkIncludeFile.c(1,1): fatal  error C1083: Cannot open include file: 'pthread.h': No such file or directory
CheckIncludeFile.c(1,1): fatal  error C1083: #include <pthread.h>

I already have github app and I used it to clone my project, but for some reason CMake needed Git for windows, so if anyone had this issue this is what worked for me after hours of search

ma1169
  • 659
  • 1
  • 8
  • 26