You are on page 1of 8

17-Mar-11 How to Install C and C++ Compilers in …

Ubuntu Linux Tutorials,Howtos,Tips & News | Karmic,Lucid,Maverick

Search

Home
Forum
Free Ubuntu E-Books
Submit Article
Top Posts
Ubuntu Hosting
Contact
About
Subscribe
Sitemap
Privacy Policy
Search

Ads by Google DVD Install Ubuntu Dish Install Cygw in GCC PC Install

Sponsor

Ads by Google
Ubuntu Linux Desktop
Install Softw are
Install Window s
Computer Install
Vista Install

Categories
Backup
Free Books
General
Monitoring
Networking
D:/…/how-to-install-c-and-c-compilers-i… 1/8
17-Mar-11 How to Install C and C++ Compilers in …
News
Package Mgmt
Security
Server

Sponsor

Ads by Google
Linux Install
PC Install
Install Image
Install MSN
Install Update

Login/Register
Register
Log in

Archives
Select Month

How to Install C and C++ Compilers in Ubuntu


and testing your first C and C++ Program
May 4, 2008 · General · Email This Post
Share 66

If you're new here, you may want to subscribe to my RSS feed and if you have questions related to your
ubuntu system post question to our forums. Thanks for visiting!

If you are a developer you need C and C++ 7 retw eet


Compiler for your development work.In ubuntu you can
install the build-essential for C and C++ compilers.

Install C and C++ Compilers in Ubuntu

sudo aptitude install build-essential

This will install all the required packages for C and C++
compilers

D:/…/how-to-install-c-and-c-compilers-i… 2/8
17-Mar-11 How to Install C and C++ Compilers in …
Testing C and C++ Programs

Compiling Your first C Programs

Now you need to open first.c file

sudo gedit first.c

add the following lines save and exit the file

Firstly compile the code using the following command

cc -c first.c

that would produce an object file you may need to add to the library.

then create an executable using the following command

cc -o first first.c

Now run this executable using the following command

./first

Output should show as follows

Hello, world

Compiling your first C++ program

If you want to run c++ program follow this procedure

g++ is the compiler that you must use.

you should use a .cpp file extension rather than a .c one

You need to create a file

sudo gedit first.cpp

add the following lines save and exit the file

D:/…/how-to-install-c-and-c-compilers-i… 3/8
17-Mar-11 How to Install C and C++ Compilers in …

Run your C++ Program using the following command

g++ first.cpp -o test

./test

Output should show as follows

Hello World!

Red Hat Linux System HTCampus.com/RedHat


Register Now for Certification in Red Hat Linux
System Administration
SysOps at SlideShare www.slideshare.net
50 million unique visitors /month Can you handle
the traffic?
Windows Job Scheduler www.OnLineToolWorks.com
Free Edition, Enterprise, easy- to-use, advanced
job scheduler
Fast PowerBasic Compilers www.powerbasic.com
Faster than C? Easy as Basic? No trace of bloat
- Free details !

Related Articles

Change Font Colour in Gnome Panels (7)


Fix your laptops brightness function keys operating properly in Hardy (30)
Creating Custom Ubuntu Live-CD With Remastersys (44)
Select Preferred Applications in Ubuntu (2)
Show and hide the GRUB Menu on Ubuntu (3)
Disable Synaptics Touchpad While Typing in Ubuntu (4)
Dual Monitors with NVidia in Ubuntu (84)
How to play Wmv9 files on AMD64 Ubuntu (5)
Combine multiple PDFs into one file in Ubuntu Linux (6)

← How to Install Kiba-Dock in Ubuntu 7.10 (Gutsy Gibbon)


D:/…/how-to-install-c-and-c-compilers-i… 4/8
17-Mar-11 How to Install C and C++ Compilers in …
How to Enable Automatic Login in Ubutnu →

124 Comments to “How to Install C and C++ Compilers in Ubuntu and testing your
first C and C++ Program”
1. Rudra says:
November 25, 2010 at 6:26 pm

@ Pral
Hey in unix system there are no drive concept (like c:\,d:\ etc). all are these declare as a file system. you
can find them at /media/(file system name). you want to paste some .h file? but there are no need for this
because ubuntu have preinstall these library files.

2. Rodrigo says:
December 2, 2010 at 11:20 am

Thanks for all.

3. Eddie says:
December 27, 2010 at 2:24 pm

It is useful to install manpages in addition to the compilers. You can do this for example using the following
command:

sudo apt-get install build-essential manpages-dev

…or if you have already installed the build-essential package:

sudo apt-get install manpages-dev

4. joseph Daniel says:


January 19, 2011 at 4:46 pm

Thanks for all

← Older comments

Leave a Reply

Name (required)

Mail (will not be published) (required)

Website

D:/…/how-to-install-c-and-c-compilers-i… 5/8
17-Mar-11 How to Install C and C++ Compilers in …

Notify me of followup comments via e-mail

← How to Install Kiba-Dock in Ubuntu 7.10 (Gutsy Gibbon)


How to Enable Automatic Login in Ubutnu →

Recent entries Free Ubuntu E-Book


How to install Cairo Dock in Ubuntu 10.10 A Complete
(Maverick)
Beginner's Manual
Introduction to GNU/Linux (PDF Guide)
for Ubuntu 10.04
How to Install Docky in Ubuntu 10.10 (Maverick)
(Lucid Lynx)
Banshee 1.9.3 released and Ubuntu installation
instructions included
Script command make typescript of terminal session
in Linux

Recent comments
lemon: "Pardon me for asking, but what possible
Tresopi: The second link of the previous comment
Balach Baloch: i have even tried apt-get install to ins
Balach Baloch: i have done all those steps above
but, i Getting Started with Ubuntu
fernando: Hello! First congratulations on the wond 10.04 (Lucid Ly nx) is a
comprehensive beginners guide
for the Ubuntu operating sy stem
Popular posts .
Download Now
Speed Up Firefox web browser (185)
iPhone Tethering on Ubuntu 9.10 (Karmic) (159)
Send and Receive Your Hotmail messages through
Evolution (145) RSS Feed
Atheros AR5007 wireless with madwifi on Ubuntu
8.04 (Hardy heron) (144)
D:/…/how-to-install-c-and-c-compilers-i… 6/8
17-Mar-11 How to Install C and C++ Compilers in …
How to Install Java Runtime Environment (JRE) in
Ubuntu (139)

© 2006-2010 · All rights reserved. · Ubuntu Geek

UbuntuGeek on Twitter

Watch Demo on SSL


VPNs
Juniper provides cost-
effec tive sec ure
ac cess for mobile
workforce
Junipe r.net/in/e n/dm /ssl…

Professional Linux
Laptop
Linux on M6500,
M4500, E6510, E4310
Fedora, Ubuntu, RHEL,
Debian, Slack
www.Em perorLinux .com

AI Planning &
Scheduling
encodes expert
knowledge to solve
problems with complex
constraints
www.stottle rhe nk e .com /

Learn embedded
linux $219
Hands-on kit teaches
fundamentals of
embedded Linux
development
www.Inte lliMetrix.us

440+ of Linux
Openings
Exp: 0 to 13 Yrs.Sal:
25k to 95k PM Apply
Now & get Multiple
Interviews
Tim e sJobs.com /C ++_Lin…

RAID Data Recovery


Data Recovery
HP Coupons Codes
Server data recovery

D:/…/how-to-install-c-and-c-compilers-i… 7/8
17-Mar-11 How to Install C and C++ Compilers in …
Web Hosting

Support Ubuntugeek
Amount $: 5.00
Website(Optional):

Favourite Sites
My Daily Tech Tips
Chrome OS Geek
Windows Reference
Debian Admin
DebianHelp
SuSe Linux Tutorials
Ubuntux
Tuxmachines
Unixmen
Arabic ubuntu support

D:/…/how-to-install-c-and-c-compilers-i… 8/8

You might also like