Find the answer to your Linux question:
Results 1 to 10 of 10
Hi, I am trying to do C programming in linux. The default shell I use is bash. Is there a shell to do C programming? This is because when i ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2003
    Posts
    25

    How to program in C in linux?


    Hi,
    I am trying to do C programming in linux. The default shell I use is bash.
    Is there a shell to do C programming?

    This is because when i type 'gcc -ansi hello.c -o hello.c' , there is an error message saying that the command is not found.

    What command should I type to get to the correct shell ?

  2. #2
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    1. There is no certain shell that you have to use to compile programs in C

    2. You need to check if gcc is installed on your system. To do that, run 'which gcc'. If it gives you a full path name, then you have it installed.

    3. Your command 'gcc -ansi hello.c -o hello.c' is wrong.
    a. Your option '-o hello.c' should be something like '-o hello.exe' With the command you are using, you are trying to compile the source code file 'hello.c' into your executable. That's just plainly wrong.
    b. I believe you need to specify all options BEFORE the source file name. Hence, you can try something like 'gcc -ansi -o hello.exe hello.c'. Note that the order is different than your code.

    4. You can type 'ps' to see the processes that you are currently running. It will show the shell that you are currently in.
    The best things in life are free.

  3. #3
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Like bpark said, you probably just don't have gcc installed; most distributions don't install it by default. Just pop in your distribution CD and install it, and you should be fine.

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Aug 2003
    Location
    Ohio
    Posts
    25
    i have the same prob, but when i put my cd in to install it says that i need to update my sources...i try it(updating) and same thing happens

  6. #5
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    What distribution?

  7. #6
    Just Joined!
    Join Date
    Aug 2003
    Location
    Ohio
    Posts
    25
    i have mandrake 9.0 and it just won't let me install a gcc

  8. #7
    Just Joined!
    Join Date
    Jun 2003
    Location
    Helsinki, Finland
    Posts
    78
    Are you installing as the root user or as a normal user?

  9. #8
    Linux User
    Join Date
    Feb 2003
    Location
    Norway, Asker
    Posts
    267
    just "urpmi gcc" and I think it should install gcc

  10. #9
    Just Joined!
    Join Date
    Aug 2003
    Location
    Ohio
    Posts
    25
    i tried installing first as normal user then as root neither of them worked i received the "installation error" for both

  11. #10
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    What method are you using to install it, and exactly what error message do you get?

Posting Permissions

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