LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-19-2011, 10:43 AM   #1
Piyush M
Member
 
Registered: Jan 2011
Location: Maharashtra,India
Distribution: debian 7.2
Posts: 125

Rep: Reputation: 6
Question 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
 
Old 01-19-2011, 10:52 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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.

Last edited by paulsm4; 01-19-2011 at 10:57 AM.
 
Old 01-19-2011, 11:25 AM   #3
almatic
Member
 
Registered: Mar 2007
Distribution: Debian
Posts: 547

Rep: Reputation: 67
Quote:
Originally Posted by paulsm4 View Post
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'
 
Old 01-19-2011, 11:42 PM   #4
Piyush M
Member
 
Registered: Jan 2011
Location: Maharashtra,India
Distribution: debian 7.2
Posts: 125

Original Poster
Rep: Reputation: 6
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.

Last edited by Piyush M; 01-19-2011 at 11:51 PM.
 
Old 01-19-2011, 11:58 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,374

Rep: Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383
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)
 
Old 01-20-2011, 12:07 AM   #6
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,680
Blog Entries: 29

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
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.

Last edited by TheIndependentAquarius; 01-20-2011 at 12:18 AM.
 
Old 01-20-2011, 12:25 AM   #7
kindofabuzz
Member
 
Registered: Mar 2010
Location: There
Distribution: Linux Mint 17.1
Posts: 237

Rep: Reputation: 45
Gedit is great for all languages.
 
1 members found this post helpful.
Old 01-20-2011, 12:28 AM   #8
appilu
Member
 
Registered: Jan 2011
Distribution: RedHat,Debian-Ubuntu,Fedora
Posts: 73

Rep: Reputation: 8
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

Last edited by appilu; 01-20-2011 at 12:29 AM.
 
1 members found this post helpful.
Old 01-20-2011, 12:31 AM   #9
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,680
Blog Entries: 29

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
Quote:
Originally Posted by appilu View Post
I think gcc comes preloaded with Ubuntu.
No it doesn't, Ubuntu lacks even the "man pages" by default!, BTW welcome to LQ.

Last edited by TheIndependentAquarius; 01-20-2011 at 12:32 AM.
 
1 members found this post helpful.
Old 01-20-2011, 12:38 AM   #10
appilu
Member
 
Registered: Jan 2011
Distribution: RedHat,Debian-Ubuntu,Fedora
Posts: 73

Rep: Reputation: 8
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
 
Old 01-20-2011, 12:48 AM   #11
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,680
Blog Entries: 29

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
Quote:
Originally Posted by appilu View Post
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
 
Old 01-20-2011, 05:08 AM   #12
appilu
Member
 
Registered: Jan 2011
Distribution: RedHat,Debian-Ubuntu,Fedora
Posts: 73

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Language on LTSP client on Ubuntu 9.04 avinash.rao Ubuntu 1 08-03-2009 11:48 AM
How can I write a virtual disk with c language in ubuntu? kian Ubuntu 4 04-13-2009 06:22 AM
Adding a System Language on Ubuntu 7.04 ClrScr Linux - General 2 08-07-2007 12:32 PM
Adding a System Language on Ubuntu 7.04 ClrScr Linux - General 3 08-06-2007 09:34 PM
Latin Language Support in Ubuntu moo-cow Ubuntu 1 10-04-2006 08:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration