LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   c language in ubuntu 10.10 (https://www.linuxquestions.org/questions/linux-newbie-8/c-language-in-ubuntu-10-10-a-857302/)

Piyush M 01-19-2011 10:43 AM

c language in ubuntu 10.10
 
I have installed new ubuntu 10.10 in my lenovo laptop.I know gcc is used for c language but pls help me with detail info about running c in ubuntu.
thank you

paulsm4 01-19-2011 10:52 AM

1. Install C (if it isn't already present).
Cut/paste this command:
Quote:

sudo apt-get install gcc g++ gdb make manpages-dev build-essential linux-headers-`uname -r`
2. Write a "hello world" test program:
Quote:

vi hello.c
Code:

#include <stdio.h>

int
main (int argc, char *argv[])
{
  printf ("hello world\n");
  return 0;
}

3. Compile:
Quote:

gcc -g -Wall -pedantic -o hello hello.c
4. Run:
Quote:

./hello
5. You'd use probably use tools like Eclipse or make to develop projects.

almatic 01-19-2011 11:25 AM

Quote:

Originally Posted by paulsm4 (Post 4230318)
1. Install C (if it isn't already present).
Cut/paste this command:

Code:

sudo apt-get install gcc g++ gdb make manpages-dev build-essential linux-headers-`uname -r`

not quite sure why you want to install the kernel-headers for that. You maybe meant the glibc (c standard library), which is 'libc6-dev' and contains the headers like 'stdio.h'

Piyush M 01-19-2011 11:42 PM

Thanks a lot my dears.
You are first to reply me and wise also.
I tried the code but it does not work..uname is not found.Pls tell me from basic and explaining everything.also I have Gvim text editor so is it usefull in c programming?
pls reply.

chrism01 01-19-2011 11:58 PM

uname is a std cmd: it's possible you used single quotes(') instead of backquotes (`).

you could try this format instead
Code:

sudo apt-get install gcc g++ gdb make manpages-dev build-essential linux-headers-$(uname -r)

Aquarius_Girl 01-20-2011 12:07 AM

Also you can select "synaptic Package Manager" through "System" menu and put gcc etc. in the search bar, the relevant packages will automatically get selected and then then...
http://www.ubuntugeek.com/synaptic-p...ntu-users.html

Quote:

Originally Posted by Piyush M
I have Gvim text editor so is it usefull in c programming?

No idea what is Gvim, but I suggest you to stick to Vim for a start, if you run into problems various people will be here to help you w.r.t Vim.
Vim is there by default.

kindofabuzz 01-20-2011 12:25 AM

Gedit is great for all languages.

appilu 01-20-2011 12:28 AM

Hi Piyush ,
I think gcc comes preloaded with Ubuntu.
Give 'which gcc ' so that you can ensure whether gcc is on place.
If no gcc present you can install it using package manager or can download,compile&install.

#include <stdio.h>
main ()
{
printf ("BOss My Generation from C \n");
}
Suppose your filename is print.c,take a terminal

Method I:

YOu can compile with gcc print.c,generates a file a.out,
to compile that give ./a.out in the directory where a.out is present.

Method II:


compile with gcc print.c -o output
then run ./output instead of a.out in previous case.
you can give whatever name instead of output,u like:cool:

Aquarius_Girl 01-20-2011 12:31 AM

Quote:

Originally Posted by appilu (Post 4231052)
I think gcc comes preloaded with Ubuntu.

No it doesn't, Ubuntu lacks even the "man pages" by default!, BTW welcome to LQ.

appilu 01-20-2011 12:38 AM

What ever man pages we want,
we can install later using apt-get install ,so its not an issue i thnk so
thnks to anisha

Aquarius_Girl 01-20-2011 12:48 AM

Quote:

Originally Posted by appilu (Post 4231062)
What ever man pages we want, we can install later using apt-get install ,so its not an issue i thnk so

That can be an issue if you don't have an internet connection ;)

appilu 01-20-2011 05:08 AM

its right anisha, for apt a netconnection is required.
From my experience am saying without net its bored to work on linux.


All times are GMT -5. The time now is 03:43 PM.