LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-27-2008, 12:54 AM   #1
serconsult
LQ Newbie
 
Registered: Jul 2008
Posts: 12

Rep: Reputation: 0
gcc cannot find stdio.h


I am trying to compile a simple c program on Redhat v9.2.

--- program code ----
#include < stdio.h >

main()
{
char s[4];
int i;
char *s2;

strcpy(s, "Jim");
i = (int) s;
printf("i = %ld (0x%lx)\n", i, i);
printf("s = %ld (0x%lx)\n", s, s);

i++;
s2 = (char *) i;
printf("s = 0x%lx. s2 = 0x%lx, i = 0x%lx, s[0] = %c, s[1] = %c, *s2 = %c\n",
s, s2, i, s[0], s[1], *s2);
}

--- end program code ----


I execute the compiler

$root: /u/c>gcc -I/usr/include -v -o p8 p8.c

--- gcc response ---
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20070626 (Red Hat 4.1.2-14)
/usr/libexec/gcc/i386-redhat-linux/4.1.2/cc1 -quiet -v -I/usr/include p8.c -quiet -dumpbase p8.c -mtune=generic -auxbase p8 -version -o /tmp/cctWroQw.s
ignoring nonexistent directory "/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/include"
ignoring duplicate directory "/usr/include"
as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/i386-redhat-linux/4.1.2/include
/usr/include
End of search list.
GNU C version 4.1.2 20070626 (Red Hat 4.1.2-14) (i386-redhat-linux)
compiled by GNU C version 4.1.2 20070626 (Red Hat 4.1.2-14).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 6f8a93af44427a05901e7b3a98a7b357
p8.c:1:21: error: stdio.h : No such file or directory
p8.c: In function âmainâ:
p8.c:9: warning: incompatible implicit declaration of built-in function âstrcpyâ
p8.c:11: warning: incompatible implicit declaration of built-in function âprintfâ
--- end error response from gcc ---

I have verified that the file exists

root: /usr/include>ls -l stdio.h
-rw-r--r-- 1 root root 28341 Oct 15 2007 stdio.h
root: /usr/include>

Can anyone explain why this will not compile?
 
Old 07-27-2008, 01:35 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
why did you put spaces around "stdio.h"?????

It should look like this:
Code:
#include <stdio.h>
 
Old 07-27-2008, 09:31 AM   #3
serconsult
LQ Newbie
 
Registered: Jul 2008
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks

That solved the problem with finding the headers, thanks. I did have one additional problem, the strcpy command was not found in stdio.h and I had to add string.h.
 
Old 07-27-2008, 10:41 AM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Please post code and compiler output in [code] tags to aid readability.

I notice that you are building these test programs as the root user. This is not good practice - you should use a non-privileged user account for all activities which do not require root access (i.e. all non-admin activities).
 
Old 08-03-2008, 07:26 PM   #5
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by serconsult View Post
That solved the problem with finding the headers, thanks. I did have one additional problem, the strcpy command was not found in stdio.h and I had to add string.h.
That's because it belongs in <string.h>.
ta0kira
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gcc compiler cannot find header file stdio.h / stdlib.h debianlam Programming 2 05-11-2008 02:29 PM
gcc compiler cannot find header file stdio.h / stdlib.h debianlam Programming 2 05-09-2008 03:33 PM
gcc won't find stdio.h .... or anything else either Thulas Programming 3 02-24-2005 12:22 AM
gcc and stdio in 9.1 iansworld SUSE / openSUSE 1 10-19-2004 01:35 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration