Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
hi, how to compile c pragram in ubuntu. is it need any compiler or application. help me briefly .. new to c program...
  1. #1
    Just Joined!
    Join Date
    Nov 2007
    Posts
    52

    c programming

    hi,

    how to compile c pragram in ubuntu. is it need any compiler or application.
    help me briefly .. new to c program

  2. #2
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568
    To compile,
    Code:
    #gcc filename.c
    To run,
    Code:
    #./a.out
    Edit:
    gcc compiler comes as default in most distros.so you won't need any new compiler.
    - 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
    Blackfooted Penguin daark.child's Avatar
    Join Date
    Apr 2006
    Location
    West Yorks
    Posts
    4,344
    Another way is
    Code:
    $gcc -o prog prog.c
    $./prog

  4. #4
    Just Joined! vijay_kernel's Avatar
    Join Date
    Apr 2007
    Posts
    77
    You need to install the compiler first like,

    sudo apt-get install gcc

    if gcc is installed successfully then you can compile the program by using the "cc" or "gcc" like,

    cc hello.c or gcc hello.c

    And you need to install the library also.

  5. #5
    Linux Guru techieMoe's Avatar
    Join Date
    Aug 2004
    Location
    Texas
    Posts
    9,496
    To develop on Ubuntu, I recommend you install the "build-essential" metapackage:

    Code:
    sudo apt-get install build-essential
    That includes gcc and a host of other things.
    Registered Linux user #270181
    TechieMoe's Tech Rants

  6. #6
    Just Joined!
    Join Date
    Nov 2007
    Posts
    52
    how to create .c file and where?


    no info in ebook ...

  7. #7
    Blackfooted Penguin daark.child's Avatar
    Join Date
    Apr 2006
    Location
    West Yorks
    Posts
    4,344
    You just use an editor such as VI/M, Emacs, KATE, Gedit etc. Another option is to use an IDE like KDevelop, Anjuta, Geany, Eclipse etc. You can just sotre the files somewhere in your home directory.

  8. #8
    Just Joined!
    Join Date
    Nov 2007
    Posts
    52
    i have created a hello.c in desktop . how to compile in terminal.

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

    Smile

    Ok....In Fedora we used to Click on,
    System Tools -- > Terminal ( i guess its should be same in ubuntu )
    To get into terminal,
    From there go to ur file directory say(i assume ur login name is oss),
    Code:
    cd /home/oss/Desktop 
    gcc filename.c
    ./a.out
    HTH
    - 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
    -------------------

  10. #10
    Blackfooted Penguin daark.child's Avatar
    Join Date
    Apr 2006
    Location
    West Yorks
    Posts
    4,344
    If you want your programs to have a name thats more meaningful than a.out, the use the -o flag in gcc e.g.
    Code:
    $gcc hello.c -o hello
    You would then run the program by doing
    Code:
    $./hello

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
  •  
...