我能获得Unix的pthreads.h中在Windows编译? [英] Can I get Unix's pthread.h to compile in Windows?

查看:192
本文介绍了我能获得Unix的pthreads.h中在Windows编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我尝试编译一个程序

If I try to compile a program with

#include <pthread.h>

在这,我得到的错误:

pthread.h: No such file or directory

是否有可能得到这个在Windows环境下编译?

Is it possible to get this to compile in a Windows environment?

我使用Vista的采用最新的MinGW。

I am using Vista with the latest MinGW.

我不想使用Microsoft Windows服务的UNIX版本3.5,我将不得不这样移动到Unix环境。

I do not want to use the Microsoft Windows Services for UNIX Version 3.5 as I will have to move this to a Unix environment.

推荐答案

pthreads.h中是用于线程的Unix / Linux(POSIX)API的头部。 POSIX的层如Cygwin的可能会编译应用程序的#include&LT; pthreads.h方式&gt;

pthread.h is a header for the Unix/Linux (POSIX) API for threads. A POSIX layer such as Cygwin would probably compile an app with #include <pthreads.h>.

本地的Windows线程API是通过暴露的#include&LT; WINDOWS.H方式&gt; 和它的作品略有不同对Linux的线程

The native Windows threading API is exposed via #include <windows.h> and it works slightly differently to Linux's threading.

不过,有一个替代胶水库保持在 http://sourceware.org/pthreads-win32/ ;注意,它使用MinGW / VS一些轻微的不兼容问题(例如,参照<一个href=\"http://stackoverflow.com/questions/33557506/timespec-redefinition-error/37072163#37072163\">here).

Still, there's a replacement "glue" library maintained at http://sourceware.org/pthreads-win32/ ; note that it has some slight incompatibilities with MinGW/VS (e.g. see here).

这篇关于我能获得Unix的pthreads.h中在Windows编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆