MinGW "stdio.h: No such file or directory"

I am trying to use MinGW to compile a C program under Windows XP. Gcc.exe produces the following error:

stdio.h: no such file or directory

The code (hello.c) looks like this:

#include < stdio.h > void main() { printf("\nHello World\n"); } 

I am using a batch file to call gcc. The batch file is as follows:

 @echo off set OLDPATH=%PATH% set path=C:\devtools\MinGW\bin;%PATH% set LIBRARY_PATH=C:\devtools\MinGW\lib set C_INCLUDE_PATH=C:\devtools\MinGW\include gcc.exe hello.c set path=%OLDPATH% 

I tried the -I option with no effect. What am I doing wrong?

+6
c compiler-construction
source share
4 answers

Try changing the first line to:

 #include <stdio.h> 

without spaces. He tries to find a file called "stdio.h" with a space at the beginning and end.

+6
source share

You should try installing MinGW in the default installation directory (i.e. C: \ MinGW), which I read many times, so it was recommended to avoid problems. There may be (erroneously) hard code in gcc.

+2
source share

Also note that main () should return int:

 int main(void) 
0
source share

you can use

$ sudo apt-get install build-essential

to solve this problem

0
source share

All Articles