Go Back   TechArena Community > Software > Operating Systems
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



how to install c++ on ubuntu

Operating Systems


Reply
 
Thread Tools Search this Thread
  #1  
Old 03-01-2011
Member
 
Join Date: Dec 2010
Posts: 68
how to install c++ on ubuntu
  

I want to install c++ on ubuntu, I never have a experience of installation on ubuntu. I want to install, compile,run a program on ubuntu operating system.i had try to install the ubuntu, but i?m not succeed, I don?t understand anything because, I?m not use too on ubuntu and the installation procedure on windows and ubuntu are different. Please help me on this. Please suggest some tips for installation.

Reply With Quote
  #2  
Old 03-01-2011
Member
 
Join Date: May 2008
Posts: 860
Re: how to install c++ on ubuntu

You need a c++ compiler for your development work in ubuntu. Install c++ compiler in ubuntu. udo aptitude install build-essential This will install all the required packages for C++ compilers.
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

Run your C++ Program using the following command
g++ first.cpp -o test
./test
Output should show as follows
Hello World!
Reply With Quote
  #3  
Old 03-01-2011
Member
 
Join Date: May 2008
Posts: 913
Re: how to install c++ on ubuntu

To use c++ on ubuntu first you need to install c++ compiler on ubuntu. In C++ compilers are not pre-installed in Ubuntu. First of all, install build-essential package. This package will install all compiler
and other necessary packages required for compilation.
Code:
sudo apt-get update
sudo apt-get install build-essential
You can use any text editor or IDE for compilation.
Reply With Quote
  #4  
Old 03-01-2011
Member
 
Join Date: Nov 2008
Posts: 1,054
Re: how to install c++ on ubuntu

You need a sudo aptitude install build-essential
This will install cc (C) and g++ (C++) compilers and some others
For example:
Using the vi editor to open a file called hello.c:
vi hello.c
and type:
1 #include <stdio.h>
2
3 int main()
4 {
5 printf("Hello world!\n");
6 return 0;
7 }
Now compile the program:
gcc hello.c -o hello
A new file called ?hello? should be created, run it using:
./hello
output:
Hello world!
The above code will provide all essential build-in for installation.
Reply With Quote
  #5  
Old 03-01-2011
Member
 
Join Date: May 2008
Posts: 979
Re: how to install c++ on ubuntu

For installation of C++ on ubuntu you first you need to install the c++ compiler on ubuntu you can use G++ compiler an advanced compiler with lot of features.To install G++ type following command at command line.
sudo apt-get install g++
Compilation of c++ on ubuntu:
user1004@user1004-desktop:~/Desktop$ g++ decbin2.cpp
user1004@user1004-desktop:~/Desktop$ ./a.out
Enter the decimal number to be converted
23
The Equivalent binary number is 010111
This will install c++ compiler on your system.
Reply With Quote
  #6  
Old 03-01-2011
Member
 
Join Date: Nov 2008
Posts: 996
Re: how to install c++ on ubuntu

For installation you need to install Update package index first:
$ sudo aptitude update
Install required packages
For code development, you'll also need some additional packages. Run
$ sudo aptitude install build-essential gdb subversion

$ sudo aptitude install automake autoconf libtool

$ sudo aptitude install libgtk2.0-dev libxmu-dev libxxf86vm-dev

these packages are specially for programming with the wxWidgets GUI toolkit Code::blocks itself is a pure wxWidgets product.
$ sudo aptitude install libwxbase2.8-dev wx2.8-headers libwxgtk2.8-dev wx-common
Then start the codeblocks IDE from the Application -> Programming menu or type:
$ codeblocks
The first launch will ask the compiler name. The default c/c++ compiler in Linux is "GNU GCC compiler".
Select it and then done. If you face any problem during installation you can also follow the video clip of installation on internet.
Reply With Quote
  #7  
Old 30-10-2011
Member
 
Join Date: Oct 2011
Posts: 1
Re: how to install c++ on ubuntu

Thank you so much, the information u provided is so great ; best thanks
Reply With Quote
Reply

  TechArena Community > Software > Operating Systems
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "how to install c++ on ubuntu"
Thread Thread Starter Forum Replies Last Post
How to install XP after Ubuntu AaAgMaN Operating Systems 4 30-01-2011 07:39 PM
how to install vb.net on ubuntu Mustafa k Operating Systems 5 03-01-2011 07:07 PM
how to install c on ubuntu Mast Maula Operating Systems 5 03-01-2011 05:04 PM
How to install JRE on Ubuntu abbase Operating Systems 4 12-10-2009 11:20 AM
Install IE in Ubuntu KDE_RuLeZ Operating Systems 3 31-08-2009 07:34 PM


All times are GMT +5.5. The time now is 09:52 PM.