How to fix fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory

Mahankali, Sai Charan 0 Reputation points
2023-08-21T12:25:06.1933333+00:00

Hi all,

I am trying to install detools package from pypi using "pip install detools"

In the process of installing, initially I got some error regarding the requirement of C++ Build tools as detools contains some c++ extensions need to be compiled. I have installed the build tools as per the documentation.

Now, iam getting the following error logs

  "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\Mahanksa\Anaconda3\include -IC:\Users\Mahanksa\Anaconda3\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" /Tcdetools/libdivsufsort/divsufsort.c /Fobuild\temp.win-amd64-cpython-39\Release\detools/libdivsufsort/divsufsort.obj
      divsufsort.c
      detools/libdivsufsort/divsufsort.c(5): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for detools
  Running setup.py clean for detools
Failed to build detools
ERROR: Could not build wheels for detools, which is required to install pyproject.toml-based projects

Any help is highly appreciated

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

2 answers

Sort by: Most helpful
  1. RLWA32 45,701 Reputation points
    2023-08-22T07:31:52.98+00:00

    The command prompt shortcuts that are created by the Visual Studio Installer properly configure environment variables for running the command line tools. These variables set paths for C/C++ include files and paths to be searched for libraries.

    I also have the 10.0.20348.0 version of the Windows SDK installed and the "stdio.h" file is provided by the Windows SDK. As a component of the UCRT, it is located at "C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\ucrt\stdio.h".

    So it seems to me that you are probably not using a VS provided command line environment and the CL.exe command line does not provide the path needed for files from the Windows SDK as shown above. At a minimum the CL.exe command line needs /I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\ucrt"


  2. Lucas Smith 0 Reputation points
    2024-11-18T10:06:08.68+00:00

    Most likely you will be able to compile your c file from the Developer Command Prompt for VS using the command: cl <source code file path>

    This is because the Developer Command Prompt for VS loads all the environment variables needed to find the standard c libraries, that are distributed in various Visual Studio and SDK paths in Windows.

    The three key environment variables for C library locations are: INCLUDE, LIB AND LIBPATH.

    You can solve this problem permanently by creating these three variables in your Windows Environment Variables (system variables) and populating them with the values used by the Developer Command Prompt for VS.

    To see the values to use, run the set command in the Developer Command Prompt for VS. If you also run the set command in a normal windows command prompt you can Diff the two outputs and see what you are missing outside the Developer Command Prompt for VS environment.

    There's probably a better way to configure the build tools in Visual Studio Code to find the C standard libraries for building and debugging, but I haven't worked out where to do that.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.