fatal error C1083: Cannot open include file: 'pthread.h': No such file or directory

Dileep Sanker 1 Reputation point
2020-08-25T18:14:38.467+00:00

Hi,

I have VS 2017 and add the pthread plugin in my VS 2017. After add pthread, throwing buils error as,
messagelogger\messagelogger.shared\messagelogger.h(30): fatal error C1083: Cannot open include file: 'pthread.h': No such file or directory.

Thanks & Regards,
Dileep

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,627 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 27,356 Reputation points Microsoft Vendor
    2020-08-26T05:13:01.94+00:00

    Hello Dileep,

    How do you add the pthread plugin to VS 2017? pthread is for Linux POSIX threads and isn’t combined with Visual Studio, you can try to use NuGet packages or Vcpkg to install and use pthread.

    For NuGet packages, please launch Visual Studio 2017 and select your project > right-click your project > choose Manage NuGet Packages… > Browse > search and find pthreads > Install.

    20338-screenshot3.png

    For Vcpkg, please refer to this document Installation(Vcpkg), and follow steps below to install Vcpkg.

    1. Go to https://github.com/Microsoft/vcpkg > clone the vcpkg repo and download it to any folder location that you prefer.
    2. Press Windows key + R to start Run and type cmd to open command prompt > type cd XXXX\XXXXX\... to change to the directory where you used to save Vcpkg folder.
    3. Type bootstrap-vcpkg.bat (Windows) to install Vcpkg.
    4. Type vcpkg.exe install pthread to install pthread.

    20385-screenshot2.png

    1. Run vcpkg integrate install to configure Visual Studio to locate all vcpkg header files and binaries on a per-user basis. You can refer to more details from here: Integrate with Visual Studio (Windows).
    2. If the pthread.h file still can’t be found by VS, you can try to include it manually, for example right-click your project > Properties… > Configuration Properties > VC++ Directories > Reference Directories > Edit > add a new line(path) which points to the folder that includes the pthread.h file (Maybe under this path C:\Users[user name]\AppData\Local\vcpkg\XXXX\XX\XXX\include\pthread.h).

    Best Regards,
    Tianyu

    1 person found this answer helpful.
    0 comments No comments