June 21, 2007...4:35 PM

Installing Compilers (GCC,G++ and Java) on UBUNTU

Jump to Comments

This tutorial is not written from scratch. I would like to thank all people who
enlightened me about Linux and Open source. This tutorial acknowledges the
help of Ubuntu Community (Docs) and people at online forums who cleared
my doubts on compilers.
Installing compilers is one of the easiest things there out at Linux. It
may seem a bit tough and complicated in the beginning but apt-get
and Synaptic Package Manager simplify your work a lot. As a newbie
developer you would require a C/C++ and a Java compiler. Installing
them is a matter of few commands.
The GNU C and GNU C++ Compiler:
The GNU C compiler is also called gcc and C++ is called g++. You
may also require the GNU make utility. All of them can get installed
by getting the build-essential package.
Just use this command:
sudo apt-get install build-essential
The GNU Java Compiler:
Firstly note that this compiler is not the one provided by Sun. The GNU
Java compiler is named as gcj. Just install the package gcj
To install the GNU Java bytecode interpreter, install the gij package.
To have gcj compile to executables, install libgcj6-dev
Use the command:
sudo apt-get install gcj gij libgcj6-dev

UPDATE ON 10th July,2006:

Some people complain that the above method does not work on their system. Errors like “build-essential not found” are displayed. Here is an alternate way of doing the same:
Most people want to use linux in GUI mode just like windows. If this the case then why use the terminal? Just open the Synaptic Package Manager and search for the package gcc. Select the package, some more packages will be highlighted and will be asked to also be included in the install process. These are dependencies. Select them also and click on Apply. The packages are download and installed. To install g++,make and gcj just do the same as above mentioned for gcc package.
Well its done, now try compiling, it should work.

15 Comments

  • i typed the command sudo apt-get install built-essential and the system responded with an error ” couldnt find package built-essential” plz help

  • I suggest you to install it via synaptics package manager, in synaptics just search the package gcc, all the dependecies will be shown and you will be asked to download these also….
    After doing the above steps, try downloading g++ which is the C++ compiler for linux,its always better to install packages via Synaptics if you are not very confident as it gives you all the dependencies also….
    Hope you have an active internet connection,its required…

  • Perhaps you’re getting errors because of the typo – it’s build-essential, not built-essential.

  • @Daniel

    Thanks, it was a typing mistake, corrected it…

  • Hi
    I dont have internet connection is there any way i can install build essential. I am really in need please help.

  • build-essential is there in the CD. Just put in the install CD and install it from there.

  • This is all i need.Thank you very much Sir.
    Can you tell me more about the packages,i mean i want to download the packages with a .deb extension & want to install it latter manually from the terminal.How can I do so?
    Please help…

  • I dont suggest you to get a .deb package and install manually.
    Manual installation is a pain as most of the packages have dependencies which are difficult to track down manually. Use the package manager and it does everything for you

  • chandra sekhar

    i am not able to install even 1 package yet.all the package installations give an error saying unable to connect to the website while i have a net connection what shud i do?

  • Chandra,
    Are you behind a proxy? This problem comes when you are behind a proxy, even though internet may be fine, Apt must know about the proxy server.

  • ITS NICE one

  • i want to install gcc, but i didn’t have connection internet.How i can…Please Help me

  • Put in the Ubuntu CD in the tray, Goto System>Administration>Software Sources and select CD. Click on Close, it would ask you to reload the index. Click “Reload”

    Now goto synaptic package manager and select “build-essential” package and its done.

  • I went to Synopsis Pckg Mngr and did the same you said above to install gcc compiler but still when I go to terminal andtype gcc it says “no input files”
    What is wrong?

    Thanks

    • You need to use gcc with filenames are input, gcc isnt a GUI compiler.
      Use it like this

      gcc inputfile.c -o outputfile

      then execute it:

      ./outputfile

      Example:

      gcc server.c – o server
      ./server


Leave a Reply