stdio.h: No such file or directory.


11 posts
by D.E.L.B. » Sat Sep 08, 2012 6:02 pm
I tried compiling a program with gcc, and this error came up, what's wrong? I am using the Raspbian OS, does Raspbian not have GCC?
User avatar
Posts: 92
Joined: Sat Jun 09, 2012 7:16 pm
Location: Wales, UK
by PeterO » Sat Sep 08, 2012 7:04 pm
If you post an example .c file that produces this error, and the gcc command lines you used, then someone might be able to help.
PeterO
User avatar
Posts: 905
Joined: Sun Jul 22, 2012 4:14 pm
by D.E.L.B. » Sat Sep 08, 2012 7:45 pm
I used this command in the LX Terminal:
gcc -o arrays_one.c arrays_one.c

Then I used this program:

Code: Select all
#include <stdio.h> int main()
{
/* Create an array with four element and assign values. */
float fourVector[4]={1.0, 2.0, 0.5, 2.292};
/* Print the number of elements in the array. */
printf("There are %ld elements\n",sizeof(fourVector)/sizeof(float)); printf("fourVector[3]=%f\n",fourVector[3]); /* Print the fourth element.*/ return 0; /* Return success to the operating system. */
}


I know you're suppose to put indents in the brackets :).
User avatar
Posts: 92
Joined: Sat Jun 09, 2012 7:16 pm
Location: Wales, UK
by PeterO » Sat Sep 08, 2012 8:08 pm
Command should be

gcc -o arrays_one arrays_one.c

But the code you've pasted is not a valid C program!

tt.c:1:20: warning: extra tokens at end of #include directive [enabled by default]
tt.c:2:1: error: expected identifier or ‘(’ before ‘{’ token

You can't put anything after the ">" of a #include line.....

However it doesn't fail with your original error.....

what output do you get fro gcc if you add "-v" switch ?

PeterO
User avatar
Posts: 905
Joined: Sun Jul 22, 2012 4:14 pm
by D.E.L.B. » Sat Sep 08, 2012 10:14 pm
Code: Select all
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.6/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.3-8+rpi1' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-sjlj-exceptions --with-arch=armv6 --with-fpu=vfp --with-float=hard --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.6.3 (Debian 4.6.3-8+rpi1)
User avatar
Posts: 92
Joined: Sat Jun 09, 2012 7:16 pm
Location: Wales, UK
by PeterO » Sun Sep 09, 2012 7:13 am
When I wrote "add the -v switch" I meant to the existing command

gcc -v -o arrays_one arrays_one.c

PeterO
User avatar
Posts: 905
Joined: Sun Jul 22, 2012 4:14 pm
by D.E.L.B. » Sun Sep 09, 2012 10:26 pm
Code: Select all
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.6/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.3-8+rpi1' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-sjlj-exceptions --with-arch=armv6 --with-fpu=vfp --with-float=hard --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.6.3 (Debian 4.6.3-8+rpi1)
COLLECT_GCC_OPTIONS='-v' '-v' '-march=armv6' '-mfloat-abi=hard' '-mfpu=vfp'
 /usr/lib/gcc/arm-linux-gnueabihf/4.6/cc1 -quiet -v -v -imultilib . -imultiarch arm-linux-gnueabihf arrays_one.c -quiet -dumpbase arrays_one.c -march=armv6 -mfloat-abi=hard -mfpu=vfp -auxbase arrays_one -version -o /tmp/ccHFOPbe.s
GNU C (Debian 4.6.3-8+rpi1) version 4.6.3 (arm-linux-gnueabihf)
        compiled by GNU C version 4.6.3, GMP version 5.0.5, MPFR version 3.1.0-p10, MPC version 0.9
GGC heuristics: --param ggc-min-expand=42 --param ggc-min-heapsize=23514
ignoring nonexistent directory "/usr/local/include/arm-linux-gnueabihf"
ignoring nonexistent directory "/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../../arm-linux-gnueabihf/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/arm-linux-gnueabihf/4.6/include
 /usr/local/include
 /usr/lib/gcc/arm-linux-gnueabihf/4.6/include-fixed
 /usr/include/arm-linux-gnueabihf
 /usr/include
End of search list.
GNU C (Debian 4.6.3-8+rpi1) version 4.6.3 (arm-linux-gnueabihf)
        compiled by GNU C version 4.6.3, GMP version 5.0.5, MPFR version 3.1.0-p10, MPC version 0.9
GGC heuristics: --param ggc-min-expand=42 --param ggc-min-heapsize=23514
Compiler executable checksum: 3c5b59c0ef1fec28e05e457a89f35c2f
arrays_one.c:1:20: fatal error: stdio. h: No such file or directory
compilation terminated.
COLLECT_GCC_OPTIONS='-v' '-v' '-march=armv6' '-mfloat-abi=hard' '-mfpu=vfp'
 /usr/lib/gcc/arm-linux-gnueabihf/4.6/cc1 -quiet -v -v -imultilib . -imultiarch arm-linux-gnueabihf arrays_one.c -quiet -dumpbase arrays_one.c -march=armv6 -mfloat-abi=hard -mfpu=vfp -auxbase arrays_one -version -o /tmp/ccHFOPbe.s
GNU C (Debian 4.6.3-8+rpi1) version 4.6.3 (arm-linux-gnueabihf)
        compiled by GNU C version 4.6.3, GMP version 5.0.5, MPFR version 3.1.0-p10, MPC version 0.9
GGC heuristics: --param ggc-min-expand=42 --param ggc-min-heapsize=23514
ignoring nonexistent directory "/usr/local/include/arm-linux-gnueabihf"
ignoring nonexistent directory "/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../../arm-linux-gnueabihf/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/arm-linux-gnueabihf/4.6/include
 /usr/local/include
 /usr/lib/gcc/arm-linux-gnueabihf/4.6/include-fixed
 /usr/include/arm-linux-gnueabihf
 /usr/include
End of search list.
GNU C (Debian 4.6.3-8+rpi1) version 4.6.3 (arm-linux-gnueabihf)
        compiled by GNU C version 4.6.3, GMP version 5.0.5, MPFR version 3.1.0-p10, MPC version 0.9
GGC heuristics: --param ggc-min-expand=42 --param ggc-min-heapsize=23514
Compiler executable checksum: 3c5b59c0ef1fec28e05e457a89f35c2f
arrays_one.c:1:20: fatal error: stdio. h: No such file or directory
compilation terminated.
User avatar
Posts: 92
Joined: Sat Jun 09, 2012 7:16 pm
Location: Wales, UK
by panik » Sun Sep 09, 2012 11:46 pm
D.E.L.B. wrote:
Code: Select all
[...snip...]
arrays_one.c:1:20: fatal error: stdio. h: No such file or directory
compilation terminated.
Is that a ' ' (space) between the '.' and the 'h'?
The first line of your code should be:
Code: Select all
#include <stdio.h>
With nothing behind it and no spaces between the <>.
Posts: 267
Joined: Fri Sep 23, 2011 12:29 pm
Location: Netherlands
by PeterO » Mon Sep 10, 2012 8:54 am
panik wrote:
Code: Select all
#include <stdio.h>
With nothing behind it and no spaces between the <>.

Yeah that caught my eye as well,. but there was no space there in the code that he posted earlier!
PeterO
User avatar
Posts: 905
Joined: Sun Jul 22, 2012 4:14 pm
by D.E.L.B. » Tue Sep 11, 2012 12:24 am
Not quite sure what I've done by there, ah well. Yes removing the space by the full stop in the <stdio.h> tag fixed it.

Thanks.
User avatar
Posts: 92
Joined: Sat Jun 09, 2012 7:16 pm
Location: Wales, UK
by PeterO » Tue Sep 11, 2012 9:17 am
D'OH !!!

A minor point of terminology.... Although stdio.h is enclosed in angle brackets "< >" is is NOT called a tag. Tags are found in html,xml etc files.

Also you will come across #include lines that don't use angle brackets but use normal double quotes.

#include <math.h>
#include "localIncludeFile.h"

In this example the file called math.h is searched for along the list of directories (this list is for my desktop machine NOT my pi)
/usr/lib/gcc/i686-redhat-linux/4.6.3/include
/usr/local/include
/usr/include

You can temporarily add to this list by using "-I /path/to/directory/" switch on the gcc command.

The file localIncludeFIle.h will only be looked for in the current directory (normally the one where the .c file is located).

HTH
PeterO
User avatar
Posts: 905
Joined: Sun Jul 22, 2012 4:14 pm