Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
I wrote a small c program just fooling around # include <stdio.h> main() { printf("Hello"); } when I compile cc Hello.c I get the following. Hello.c:1:20: error: stdio.h: No such ...
  1. #1
    Just Joined!
    Join Date
    Jul 2007
    Posts
    61

    stdio.h

    I wrote a small c program just fooling around

    # include <stdio.h>
    main()
    {
    printf("Hello");
    }


    when I compile

    cc Hello.c

    I get the following.

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

  2. #2
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Smile

    Header file is missing-i guess.
    remove that #include directive and compile.
    If this not works then -try and download latest gcc complier and compile again.
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  3. #3
    Just Joined!
    Join Date
    Jul 2007
    Posts
    61
    I thought the stdio header file came with C compilers.

  4. #4
    Just Joined!
    Join Date
    Mar 2008
    Posts
    23
    u should make sure g++ is installed or updated.
    i came across such error one day, then i installed g++ and it was solved. u might have gcc installed but g++ not installed. check out if they are both installed .
    then program and library included are totally right

    Cheers

  5. #5
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    In general they do, but sometimes weird things happen.

    Try and see if there is a libc or glibc package for you to install.
    DISTRO=Arch
    Registered Linux User #388732

  6. #6
    Linux Engineer rcgreen's Avatar
    Join Date
    May 2006
    Location
    the hills
    Posts
    1,114
    Try eliminating the space between the # and include
    It may be choking on that.
    Your code compiles fine for me, with or without the space, but
    then it also compiles without the include line. WTF?

  7. #7
    Just Joined!
    Join Date
    Jul 2007
    Posts
    61
    Yea I caught that. I took the space out from between # and include and it still did not work. Why would I need to install what I assume is the C++ compiler. I have tried using gcc and just plain cc. Neither works and give the same output. Who do I tell if I need to install the libc or glibc? Where would I find it?

  8. #8
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    So first off, I'm not sure about "cc". It may be an alias to gcc, or it may be another compiler altogether. In Linux, we usually use gcc (okay, some people use Intel's compiler), so it's a good idea to ensure that you're using gcc.

    You do not need a C++ compiler such as g++ if you're not compiling C++ (obviously).

    As far as knowing what you need to install: run the command "ls /usr/include/stdio.h". If you get a file listing, then you have stdio.h exists and something is wonky in your configuration. If you get a "no files found" message, then you need to install glibc, which is the actual GNU C Library.

    How to install it depends on your distro. If you're using Ubuntu, then use Synaptic to find "build-essential", and if that's already installed, check packages called "libc" or "glibc".

    What distro are you using?
    DISTRO=Arch
    Registered Linux User #388732

  9. #9
    Just Joined!
    Join Date
    Jul 2007
    Posts
    61
    There's a libc6 istalled. I don't see a plain libc.
    And there's a glibc-doc that's not installed

    Oh I found build essentials and I'm installing it now.

    And that worked it made a a.out file since I did not specify a output file name thanks!

    Now if I could get javac to work from the command line. Netbeans compiles programs fine and it uses the JDK6 that I installed. I even tried to run it from where javac was located and it still did not work.

  10. #10
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    I'm glad that it all worked!

    What happens when you try to run javac?
    DISTRO=Arch
    Registered Linux User #388732

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...