error: stdio.h: No such file or directory

This is a discussion on error: stdio.h: No such file or directory within the C Programming forums, part of the General Programming Boards category; Greetings All- I purchased the C Primer Plus by Stephen Prata, after reading the C Book Recommendations Thread on this ...

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    5

    error: stdio.h: No such file or directory

    Greetings All-

    I purchased the C Primer Plus by Stephen Prata, after reading the C Book Recommendations Thread on this forum.

    I am a beginner at C. My OS is Ubuntu.

    I am running the example on page 24 in the book and below is the code.

    Code:
    #include <stdio.h>
    int main(void)
    {
    	int num;
    	num = 1;
    	printf("I am a simple ");
    	printf("computer. \n");
    	printf("My favorite number is %d, because it is first. \n", num);
    	return 0;
    
    }

    Below is the error message I am getting when I do gcc first.c

    first.c:1:19: error: stdio.h: No such file or directory
    first.c: In function ‘main’:
    first.c:6: warning: incompatible implicit declaration of built-in function ‘printf’


    I did a google search with the search string as "stdio.h: No such file or directory", but did not find any valuable recommendations.

    If someone could give some suggestions or point me in the right direction, I would greatly appreciate it.

    Cheers
    MindLess

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,169
    It looks like you're missing some header files. I'm not familiar with Ubuntu, but maybe installing the latest version of gcc will place the header files there for you?
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    I don't know about Ubuntu, but in Fedora the file /usr/include/stdio.h belongs to the glibc-headers package. Are you using the gcc included in your distro, or one from a tarball you downloaded? In the former case, it should have pulled in dependencies like this automatically.

  4. #4
    Registered User
    Join Date
    Jun 2007
    Posts
    5
    Greetings All-

    Thankyou itsme86 and robatino for your replies.

    I am new to Ubuntu myself. I did a CD install on my laptop today.


    Quote Originally Posted by robatino View Post
    Are you using the gcc included in your distro, or one from a tarball you downloaded? In the former case, it should have pulled in dependencies like this automatically.
    gcc, was installed from the Ubuntu CD. I did not have to do anything. The version of gcc I am using is gcc (GCC) 4.1.2

    I will further look into how to resolve this.

    Cheers
    MindLess

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    maybe you have to set your include directory in the environment.

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    The following is from googling "stdio.h ubuntu gcc". It's very strange that Ubuntu doesn't install libc6-dev by default.

    http://groups.google.com/group/uk.co...16163?lnk=raot

    Edit: The following link says you should install the build-essential package.

    http://ubuntuforums.org/showthread.php?t=121123

  7. #7
    Registered User
    Join Date
    Jun 2007
    Posts
    5
    Greetings All-

    robatino, Thankyou for the links. I am able to resolve the errors from the information provided in the links.

    sudo apt-get install build-essential did the trick.

    Also, I installed Anjuta, IDE for the C/C++ programs that come with Ubuntu.

    Cheers
    MindLess

  8. #8
    Registered User
    Join Date
    Dec 2007
    Posts
    1

    @

    sudo apt-get install build-essential

    should solve this.

    ~Vinay Bhardwaj

  9. #9
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Posting a reply 6 months later to tell him the solution that he already found is what to do, is slightly wastful.

  10. #10
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,682
    Perhaps this thread should be closed lol

    ssharish

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  3. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  4. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21