Find the answer to your Linux question:
Results 1 to 5 of 5
hello, i am new to linux. i am trying to learn both c and linux. and when i tried to write my first program this is what happened. :~$ gcc ...
  1. #1
    Just Joined!
    Join Date
    Jan 2009
    Posts
    3

    Cannot compile C programs

    hello, i am new to linux.

    i am trying to learn both c and linux. and when i tried to write my first program this is what happened.

    :~$ gcc hello.c
    hello.c:1:19: 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’


    this is the program i wrote using vi

    #include <stdio.h>
    int main()
    {
    printf("hello azel");
    return 0;
    }


    please help.

  2. #2
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    Your compiler cannot find the header file stdio.h.
    Usually, this file is to be found in the /usr/include/ directory.

    If this file is in a different place, you can tell the compiler to look into that directory too with the -I option.
    Debian GNU/Linux -- You know you want it.

  3. #3
    Just Joined!
    Join Date
    Jan 2009
    Posts
    3
    thanks for replying.

    i cudn't find the header file in that location. and i dnt know how to find it anywhere else.
    somebody told me that i might not have GNU installed or it may be corrupted.

    so i tried this.

    :~$ sudo apt-get install GNU
    Reading package lists... Done
    Building dependency tree... Done
    E: Couldn't find package GNU

    now i am really confused. i am not being able to run the simplest c program.

  4. #4
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    Quote Originally Posted by priyazel View Post
    somebody told me that i might not have GNU installed or it
    may be corrupted.
    GNU is the operating system you use, consisting of thousends of programs
    You do not want to install all of these.

    What you want is the GNU Compiler Collection, "gcc", especially the C and the C++ compiler and the development runtime files.
    I think they are called "gcc", "g++". Depends on which flavour of GNU/Linux you use.

    Ubuntu?
    sudo apt-get install gcc build-essential
    Debian GNU/Linux -- You know you want it.

  5. #5
    Just Joined!
    Join Date
    Jan 2009
    Posts
    3

    Thank You

    Hey, thanks alot. I installed it, and it worked.

    finally i like linux, thanks to you.

Posting Permissions

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