Find the answer to your Linux question:
Results 1 to 9 of 9
I have made my first "Hello, world", in c and py(with help), but I can't "play" them, or see if they work. I know you have to open the terminal, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2005
    Location
    Faroe Islands
    Posts
    3

    My first "Hello, world"


    I have made my first "Hello, world", in c and py(with help), but I can't "play" them, or see if they work. I know you have to open the terminal, but what then....

    I use Ubuntu.

  2. #2
    Linux Engineer
    Join Date
    Apr 2005
    Location
    Buenos Aires, Argentina
    Posts
    908
    First you have to compile it and then run it.

    gcc -o program program.c
    chmod +x program
    ./program
    serzsite.com.ar
    "All the drugs in this world won\'t save you from yourself"

  3. #3
    Linux Engineer
    Join Date
    Apr 2005
    Location
    Belgium
    Posts
    1,429
    Unfortunately there is no Gnu C compiler in Ubuntu . You'll have to install it.

    I'm just getting into bash, maybe perl is for later .
    ** Registered Linux User # 393717 and proud of it ** Check out www.zenwalk.org
    ** Zenwalk 2.8 - Xfce 4.4 beta 2- 2.6.17.6 kernel = Slack on steroids! **

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru bryansmith's Avatar
    Join Date
    Nov 2004
    Location
    /Ontario/Canada
    Posts
    2,619
    Through Synaptic, search for gcc and install that. Then, do what serz mentioned.

    Bryan
    Looking for a distro? Look here.
    "There can be no doubt that all our knowledge begins with experience." - Immanuel Kant (Critique of Pure Reason)
    Queen's University - Arts and Science 2008 (Sociology)
    Registered Linux User #386147.

  6. #5
    Linux Engineer
    Join Date
    Jan 2005
    Location
    Chicago (USA)
    Posts
    1,028
    I suggest another distro. Ubuntu isn't really meant for peope that want to program; it's meant for "regualr people". Anyone that has good experience with Unix doesn't like it.

  7. #6
    Linux User nalg0rath's Avatar
    Join Date
    Sep 2004
    Location
    Stockholm
    Posts
    303
    Quote Originally Posted by serz
    First you have to compile it and then run it.

    gcc -o program program.c
    chmod +x program
    ./program
    Is it just me or isn't the chmod +x program step uneccesary. I have never experienced that gcc does not make the output file executable automatically. (?)

  8. #7
    Just Joined!
    Join Date
    Aug 2005
    Posts
    83
    I usually just:

    Code:
    gcc foo.c -o foo
    I never have to chmod.

  9. #8
    Just Joined!
    Join Date
    Aug 2005
    Posts
    83
    Quote Originally Posted by a thing
    I suggest another distro. Ubuntu isn't really meant for peope that want to program; it's meant for "regualr people". Anyone that has good experience with Unix doesn't like it.
    jens uses it, and he's got pretty good experience with UNIX. If you get into Ubuntu, it's great for some people. IMO it sucks, just a half-assed debian deriative.

  10. #9
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    I've not used Ubuntu, but seeing as how gcc and make are quite installable, I fail to see how this matters at all. SuSE doesn't have them by default either, but they can be obtained.

    Anywho, to sum everything up:

    Code:
    apt-get install gcc
    gcc -Wall -o foo foo.c      <-- "-Wall" enables warnings
    ./foo
    If, for some reason, this still doesn't work, then can you post the output of:
    Code:
    ls -l foo.c
    Where foo.c is the name of your source file?

Posting Permissions

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