45

OS Windows Vista Ultimate

I am trying to run a program called minimal.c. When I type at the command line:

C:\Users\nathan\Desktop>cl minimal.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86

Copyright (C) Microsoft Corporation.  All rights reserved.

minimal.c
minimal.c(5) : fatal error C1034: windows.h: no include path set

I have set all the paths:

C:\Users\nathan\Desktop>path
PATH=C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin;C:\Windows\system3
;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\ATI Technologies\AT
.ACE\Core-Static;C:\Program Files\Intel\DMIX;c:\Program Files (x86)\Microsoft S
L Server\100\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Bi
n\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\Java\jdk1.
.0_13\bin;C:\Program Files (x86)\Autodesk\Backburner\;C:\Program Files (x86)\Co
mon Files\Autodesk Shared\;C:\Program Files (x86)\Microsoft DirectX SDK (March
009)\Include;C:\Users\nathan\Desktop\glut-3.7.6-bin\glut-3.7.6-bin;C:\Program F
les (x86)\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files (x86)\Microsof
 Visual Studio 8\VC\PlatformSDK\Include;C:\Program Files (x86)\Microsoft Visual
Studio 8\VC\PlatformSDK\Include\gl

I have gone and made sure windows.h is in the directory. I'm setting the path too. It's in C:\Program Files (x86)\Microsoft Visual Studio 8\VC\PlatformSDK\Include.

I have Visual Studio 2005.

I have exhausted all possibilities. Any ideas?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131

8 Answers8

60

You could also run the vcvars32.bat file from the directory C:\Program Files\Microsoft Visual Studio 8\VC\bin (this is in your path) prior to your cl command.

Like this:

C:\Users\nathan\Desktop>vcvars32
C:\Users\nathan\Desktop>cl minimal.c

vcvars32 calls C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat which sets up the required environment for compiling and linking.

The environment variables are INCLUDE, LIB, and PATH.

The compiler looks for header files in the INCLUDE path during compile, and libraries are fetched from the LIB path during link.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kb.
  • 7,240
  • 13
  • 56
  • 75
  • 4
    i ran vcvars32 as you said and the windows.h is not a problem anymore. i dont understand that if i have the path in environment variables why it didnt work unless i run that. Do i have to run that everytime i open a commandline prior to compiling...it also wants to know where Gl.h is which is included in my path as well but its not finding it. C:\Program Files (x86)\Microsoft Visual Studio 8\VC\PlatformSDK\Include\gl –  May 31 '09 at 22:12
  • 2
    As a side note: there is also **64 bit** variant of this file: _vcvars64.bat_. – informatik01 Jun 09 '19 at 01:58
15

For me, with Visual Studio 2017,

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\vsdevcmd.bat"

is the command to use before compiling with cl.

Here is the documentation.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
khaverim
  • 3,386
  • 5
  • 36
  • 46
8

In your project folder, open a PowerShell window and run:

cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat" && cl minimal.c '
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 1
    Why do you have to write that in one line with the call command? This is the only solution that worked for me... – IceRevenge Nov 08 '22 at 17:05
6

When you started the command line, did you run the included command line shortcut that comes with the Visual Studio setup? This will set the correct environment variables for you so that the compilation will work correctly.

1800 INFORMATION
  • 131,367
  • 29
  • 160
  • 239
5

You've added your INCLUDE paths to your PATH environment variable. Use vcvars32.bat as the others have suggested.

sean e
  • 11,792
  • 3
  • 44
  • 56
1

I had the same issue getting the

fatal error C1034: stdio.h: no include path set

and after running the C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build>vcvars64.bat cmd/batch script would get the

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

error message. From here, and other posts on that page, I suspected that the Windows 10 SDK package must be installed. After installation and running the vcvars64.bat script from the path mentioned above, the problem was solved.

P.S. As explained here, an alternative to manually finding and running the above cmd/batch script, you may just do Windows Key+Q and search for Developer Command Prompt for ..., in my case it is Developer Command Prompt for VS 2022.

Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193
1

Your path variable might be too long. Windows can’t take more than 1023 characters in the PATH environment variable.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
aziz
  • 11
  • 1
0

if you have version 2017 of the compiler cl.exe (you installed Visual Studio 2017), in the command prompt you need go to "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build" and run 'vcvars32.bat' for x86 compilation or vcvars64.bat for x64 compilation.