Results 1 to 7 of 7

Thread: how to install c++ on ubuntu

  1. #1
    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.

  2. #2
    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!

  3. #3
    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.

  4. #4
    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.

  5. #5
    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.

  6. #6
    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.

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

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,445,528.14827 seconds with 17 queries