在Cygwin中找不到pthread.h



我一直在尝试将第三方库PicklingTools安装到我的windows环境中,需要使用Makefile.Linux构建它。我使用的是Cygwin的make版本4.3和g++版本9.2.0。

我的Makefile.Linux如下:

CC = g++
# CC = icc     # Intel seems to work
## With g++ --version==4.4.x, you may need -fno-strict-aliasing to get rid 
## of some annoying warnings when you compile with -O2 or above
# *****CAREFUL! g++ 4.5.1 20100924 DOES NOT WORK with Ptools and -O.  You must
# compile without optimization for that compiler to work
OC = ./opencontainers_1_8_5
OCINC = $(OC)/include
CFLAGS = -Wall -Wextra -fpic -O -fno-strict-aliasing -DLINUX_ -DOC_NEW_STYLE_INCLUDES -Wno-deprecated -I$(OCINC) -pthread -D_REENTRANT
## How to build with OCString
##CFLAGS = -Wall -O4 -DLINUX_ -DOC_USE_OC_STRING -DOC_USE_OC_EXCEPTIONS -DOC_ONLY_NEEDED_STL -DOC_NEW_STYLE_INCLUDES -Wno-deprecated -I$(OCINC) 
###### CFLAGS = -Wall -O4 -DLINUX_-DOC_NEW_STYLE_INCLUDES -Wno-deprecated -I$(OCINC) 

CCFLAGS = -pthread $(CFLAGS)
COM_OBJS = m2pythontools.o valpython.o midassocket.o valprotocol2.o m2ser.o m2streamdataenc.o m2convertrep.o timeconv.o fdtools.o
OBJS = midastalker_ex.o midastalker_ex2.o httpclient_ex.o httpserver_ex.o $(COM_OBJS) load.o save.o sharedmemory.o 
all: midasyeller_ex midastalker_ex midastalker_ex2 httpclient_ex midasserver_ex permutation_server permutation_client load save opal2dict dict2opal opaltest midasyeller_ex midaslistener_ex p2_test valgetopt_ex sharedmem_test ready_test xmlload_test xmlload_ex xmldump_test xmldump_ex speed_test pickleloader_test chooseser_test xml2dict dict2xml serverside_ex clientside_ex middleside_ex
.cc.o:
$(CC) $(CFLAGS) -c $<
libptools.so : $(COM_OBJS) 
$(CC) $(CCFLAGS) $(COM_OBJS) -shared -o libptools.so
midasserver_ex : $(COM_OBJS) midasserver_ex.o
$(CC) $(CCFLAGS) $(COM_OBJS) midasserver_ex.o -pthread -o midasserver_ex
httpclient_ex : $(COM_OBJS) httpclient_ex.o
$(CC) $(CCFLAGS) $(COM_OBJS) httpclient_ex.o -pthread -o httpclient_ex
httpserver_ex : $(COM_OBJS) httpserver_ex.o
$(CC) $(CCFLAGS) $(COM_OBJS) httpserver_ex.o -pthread -o httpserver_ex
midasyeller_ex : $(COM_OBJS) midasyeller_ex.o
$(CC) $(CCFLAGS) $(COM_OBJS) midasyeller_ex.o -pthread -o midasyeller_ex
midaslistener_ex : $(COM_OBJS) midaslistener_ex.o
$(CC) $(CCFLAGS) $(COM_OBJS) midaslistener_ex.o -pthread -o midaslistener_ex
permutation_server : $(COM_OBJS) permutation_server.o
$(CC) $(CCFLAGS) $(COM_OBJS) permutation_server.o -pthread -o permutation_server
permutation_client : $(COM_OBJS) permutation_client.o
$(CC) $(CCFLAGS) $(COM_OBJS) permutation_client.o -pthread -o permutation_client
midastalker_ex :$(COM_OBJS) midastalker_ex.o 
$(CC) $(CCFLAGS) $(COM_OBJS) midastalker_ex.o -o midastalker_ex
midastalker_ex2 :$(COM_OBJS) midastalker_ex2.o 
$(CC) $(CCFLAGS) $(COM_OBJS) midastalker_ex2.o -o midastalker_ex2
load = load
$(load) : $(COM_OBJS) load.o 
$(CC) $(CCFLAGS) $(COM_OBJS) load.o -o load
serverside_ex : $(COM_OBJS) sharedmem.o shmboot.o serverside_ex.o 
$(CC) $(CCFLAGS) $(COM_OBJS) sharedmem.o shmboot.o -lrt serverside_ex.o -o serverside_ex 
middleside_ex : $(COM_OBJS) middleside_ex.o sharedmem.o shmboot.o 
$(CC) $(CCFLAGS) $(COM_OBJS) sharedmem.o shmboot.o -l rt middleside_ex.o -o middleside_ex 
clientside_ex : $(COM_OBJS) clientside_ex.o sharedmem.o shmboot.o 
$(CC) $(CCFLAGS) $(COM_OBJS) sharedmem.o shmboot.o -lrt clientside_ex.o -o clientside_ex 
samplehttpserver_ex : $(COM_OBJS) samplehttpserver_ex.o 
$(CC) $(CCFLAGS) $(COM_OBJS) samplehttpserver_ex.o -o samplehttpserver_ex
save : $(COM_OBJS) save.o
$(CC) $(CCFLAGS) $(COM_OBJS) save.o -o save
opal2dict : $(COM_OBJS) opal2dict.o 
$(CC) $(CCFLAGS) $(COM_OBJS) opal2dict.o -o opal2dict
opaltest : $(COM_OBJS) opaltest.o 
$(CC) $(CCFLAGS) $(COM_OBJS) opaltest.o -o opaltest
ready_test : $(COM_OBJS) ready_test.o 
$(CC) $(CCFLAGS) $(COM_OBJS) ready_test.o -o ready_test
chooseser_test : $(COM_OBJS) chooseser_test.o 
$(CC) $(CCFLAGS) $(COM_OBJS) chooseser_test.o -o chooseser_test
dict2opal : $(COM_OBJS) dict2opal.o 
$(CC) $(CCFLAGS) $(COM_OBJS) dict2opal.o -o dict2opal
pickleloader_test :  $(COM_OBJS) pickleloader_test.o 
$(CC) $(CCFLAGS) $(COM_OBJS) pickleloader_test.o -o pickleloader_test -lrt
xmldump_test :  $(COM_OBJS) xmldump_test.o 
$(CC) $(CCFLAGS) $(COM_OBJS) xmldump_test.o -o xmldump_test -lrt
xmldump_ex :  $(COM_OBJS) xmldump_ex.o 
$(CC) $(CCFLAGS) $(COM_OBJS) xmldump_ex.o -o xmldump_ex -lrt
xmlload_test :  $(COM_OBJS) xmlload_test.o 
$(CC) $(CCFLAGS) $(COM_OBJS) xmlload_test.o -o xmlload_test -lrt
xmlload_ex :  $(COM_OBJS) xmlload_ex.o 
$(CC) $(CCFLAGS) $(COM_OBJS) xmlload_ex.o -o xmlload_ex -lrt
xml2dict :  $(COM_OBJS) xml2dict.o 
$(CC) $(CCFLAGS) $(COM_OBJS) xml2dict.o -o xml2dict -lrt
dict2xml :  $(COM_OBJS) dict2xml.o 
$(CC) $(CCFLAGS) $(COM_OBJS) dict2xml.o -o dict2xml -lrt

speed_test :  $(COM_OBJS) speed_test.o 
$(CC) $(CCFLAGS) $(COM_OBJS) speed_test.o -o speed_test -lrt
p2_test :  $(COM_OBJS) p2_test.o 
$(CC) $(CCFLAGS) $(COM_OBJS) p2_test.o -o p2_test -lrt
valgetopt_ex :  $(COM_OBJS) valgetopt_ex.o 
$(CC) $(CCFLAGS) $(COM_OBJS) valgetopt_ex.o -o valgetopt_ex
json_ex :  $(COM_OBJS) json_ex.o 
$(CC) $(CCFLAGS) $(COM_OBJS) json_ex.o -o json_ex
# Only the tests that REALLY uses UNIX shared memory need the -lrt
sharedmem_test :  $(COM_OBJS) sharedmem_test.o sharedmem.o
$(CC) $(CCFLAGS) $(COM_OBJS) sharedmem.o -lrt sharedmem_test.o -o sharedmem_test

# Only the tests that REALLY uses UNIX shared memory need the -lrt
checkshm_test :  $(COM_OBJS) checkshm_test.o sharedmem.o
$(CC) $(CCFLAGS) $(COM_OBJS) sharedmem.o -lrt checkshm_test.o -o checkshm_test

clean :
/bin/rm -rf *.o *.so *~ midastalker_ex midastalker_ex2 httpserver_ex httpclient_ex midasserver_ex midasyeller_ex midaslistener_ex permutation_server permutation_client load save cxx_repository opal2dict opaltest dict2opal p2_test valgetopt_ex json_ex sharedmem_test ready_test speed_test pickleloader_test chooseser_test xmldump_test xmldump_ex xmlload_test xmlload_ex xml2dict dict2xml samplehttpserver_ex serverside_ex clientside_ex middleside_ex checkshm_test

在使用make -f Makefile.Linux all构建它时,我遇到了以下错误:

g++ -Wall -Wextra -fpic -O -fno-strict-aliasing -DLINUX_ -DOC_NEW_STYLE_INCLUDES -Wno-depr
ecated -I./opencontainers_1_8_5/include -pthread -D_REENTRANT -c m2pythontools.cc
In file included from ./opencontainers_1_8_5/include/ocstreamingpool.h:23,
from ./opencontainers_1_8_5/include/ocarray.h:28,
from m2pythontools.h:8,
from m2pythontools.cc:2:
./opencontainers_1_8_5/include/ocsynchronizer.h:14:10: fatal error: pthread.h: No such fil
e or directory
14 | #include <pthread.h>
|          ^~~~~~~~~~~
compilation terminated.
make: *** [MakeFile.Linux:29: m2pythontools.o] Error 1

其中27-30行为:


.cc.o:
$(CC) $(CFLAGS) -c $<

我检查了我的/usr/include目录,发现了一个pthread.h头,有一个古老的线程提到pthread包含在cygwin1.dll中,因此可以简单地传递-lcygwin。然而,这对我来说也不起作用。我还尝试将pthread.h文件移到目录中,但仍然出现相同的错误,我不知道如何继续。

编辑:运行echo | cpp -v会产生以下输出:

Using built-in specs.
COLLECT_GCC=C:MinGWbincpp.exe
Target: mingw32
Configured with: ../src/gcc-9.2.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --t
arget=mingw32 --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-stati
c --enable-shared --enable-threads --enable-languages=c,c++,objc,obj-c++,fortran,ada --wit
h-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-libgomp
--disable-libvtv --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libs
tdcxx-debug --disable-build-format-warnings --prefix=/mingw --with-gmp=/mingw --with-mpfr=
/mingw --with-mpc=/mingw --with-isl=/mingw --enable-nls --with-pkgversion='MinGW.org GCC B
uild-20200227-1'
Thread model: win32
gcc version 9.2.0 (MinGW.org GCC Build-20200227-1)
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=i586'
c:/mingw/bin/../libexec/gcc/mingw32/9.2.0/cc1.exe -E -quiet -v -iprefix c:mingwbin../l
ib/gcc/mingw32/9.2.0/ - -mtune=generic -march=i586
ignoring nonexistent directory "c:mingwbin../lib/gcc/mingw32/9.2.0/../../../../mingw32/
include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/9.2.0/include"
ignoring nonexistent directory "/mingw/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/9.2.0/include-fixed"
ignoring nonexistent directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/9.2.0/../../../../m
ingw32/include"
ignoring nonexistent directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
c:mingwbin../lib/gcc/mingw32/9.2.0/include
c:mingwbin../lib/gcc/mingw32/9.2.0/../../../../include
c:mingwbin../lib/gcc/mingw32/9.2.0/include-fixed
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"
COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/9.2.0/;c:/mingw/bin/../libexec/gcc/;c:/m
ingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/
LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/9.2.0/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/
../lib/gcc/mingw32/9.2.0/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/9.2.0/..
/../../
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=i586'

取决于您是为Cygwin还是为Mingw构建(来自Cygwin(您需要不同的cygwin包:cygwin-develmingw64-x86_64-winpthreads

$ cygcheck -l mingw64-x86_64-winpthreads | grep /pthread.h
/usr/x86_64-w64-mingw32/sys-root/mingw/include/pthread.h
$ cygcheck -l cygwin-devel | grep /pthread.h
/usr/include/pthread.h

最新更新