Eclipse – C/C++ (CDT), Python (PyDev), and Qt (Qt4) Plugins Installation Tutorial for Ubuntu 10.04
This walk-through will take you from a fresh install of Eclipse to a fully-functional IDE ready for development of Java, Python, C/C++, and Qt GUI applications. Every step is tailored to Ubuntu but might possibly be useful to Windows/Mac users as well. Enjoy!
Now, while we’re at it, let’s make sure your browser actually uses this new browser plugin for Java applets instead of the default IcedTea plugin that’s based on OpenJDK. I have had many problems with the IcedTea browser plugin.
Anyway, back to the task at hand. Just because we have Sun Java is installed doesn’t mean Ubuntu is going to use it. If you do java -version again, you’ll note that Ubuntu still uses OpenJDK. You could uninstall OpenJDK, but that’s not necessary. We can switch which version of Java runs by default. First, though, let’s see which version of Java we just installed:
Ok, how do we switch which version of Java runs by default? Do this:
Create a GNOME menu item for Eclipse:
Just use the GUI to do this. It’s easier and more reliable. Right-click on your applications menu, choose Edit Menu, go to your Programming menu, and hit the New Item button. This way, your icon set might even have a default icon for you automatically, and you don’t have to worry about if the method below will work or not.
Here’s what to enter to create the menu item correctly:
Then click on the Add to add a software site to install from:
The CDT repository is located at http://download.eclipse.org/tools/cdt/releases/helios:
At first, I tried to just install all the available CDT options:
But after I received an error, I went back and deselected the Remote Launch package. I’m sure I don’t need all of these options, but I don’t know which ones I do need, so I just installed all of the rest as you can see below:
After making your choices, click Next. You will see an Install Details dialog containing all the software you selected to install (assuming you didn’t get an error). Just click Next. Finally, you’ll see a Review Licenses window. Just agree to the license agreement and your installation will begin:
Since Ubuntu already has g++, make, gcc, and gdb, installed and in the system path, you shouldn’t have any problem building C++ programs once CDT is finished installing. Just be sure to restart when prompted, then try it out. Go to Help → Cheat Sheets and find the Hello World application for C++. This will walk you through building a simple C++ executable.
Note: If you have problems after restarting Eclipse, exit and restart from the run dialog or terminal with the command eclipse -clean. This will clean the Eclipse cache and hopefully resolve some problems.
I don’t use Django, so I just need the main package:
Finish the Install Wizard as you did with CDT and restart Eclipse when prompted. You now have support for Java, C/C++, and Python!
Note: If you have problems after restarting Eclipse, exit and restart from the run dialog or terminal with the command eclipse -clean. This will clean the Eclipse cache and hopefully resolve some problems.
According to Qt’s website, the preferred method for installing their plugin is from outside Eclipse, so go ahead and close it first. Next, make sure you have the Qt4 Development Library installed:
Go to the location of your eclipse installation directory and extract the Qt plugin. For some reason the plugin has been archived to extract as eclipse → plugins → important stuff, so you need to be in the parent folder of your eclipse installation directory when you extract the plugin in order for everything to extract to the right place:
When you’ve finished with the dialog above, click Finish. Then click on the version you just added and click Default to make that the default Qt version:
Finally, click Apply and you should get the following dialog:
Click Yes to this dialog and then exit Preferences by clicking Ok. Now, you’re finished configuring Qt. To get started using it, go to Help → Cheat Sheets and select Qt Development. There should be an address book application walkthrough you can learn from. Here’s what my screen looked like halfway through the walkthrough. It works just like Qt Designer, but it’s running inside Eclipse.
Well that’s really it. Now you should be able to program in Java, Python, C/C++, and design Qt-based C++ GUI applications all from inside the same cross-platform IDE. Enjoy!
- Install Java
- Install Eclipse
- Install the C/C++ Development Toolkit (CDT) Eclipse Plugin
- Install the PyDev Eclipse Plugin for Python Support
- Install The Qt Eclipse Integration Plugin
First step, Install Java
By default, Ubuntu comes with the OpenJDK Runtime Environment. Honestly, I haven’t had any problems running Java applications with OpenJDK. However, I’ve read in a couple of places that Eclipse and/or some of its plugins cannot use OpenJDK. If you want to see what JRE version you have enabled, do this:~$ java -version
Getting Sun Java in Ubuntu is easy. Just do this to get everything you need (the JRE, browser plugin, development kit, and fonts):~$ sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-jdk sun-java6-fonts
Update 28APR11 – you have to make sure you’ve enabled partner repositories before the above command will work. From the Synaptic Package Manager, click on Settings → Repositores, go to the Other Software tab, and make sure Canonical Partners is checked. Thanks to HelloWorld321 for this update.Now, while we’re at it, let’s make sure your browser actually uses this new browser plugin for Java applets instead of the default IcedTea plugin that’s based on OpenJDK. I have had many problems with the IcedTea browser plugin.
~$ sudo apt-get remove icedtea6-plugin
To ensure your browser is using the Sun Java plugin, you can look at Tools → Addons or simply go to JavaTester.org to get a display of the version and vender from the JRE your browser is using.Anyway, back to the task at hand. Just because we have Sun Java is installed doesn’t mean Ubuntu is going to use it. If you do java -version again, you’ll note that Ubuntu still uses OpenJDK. You could uninstall OpenJDK, but that’s not necessary. We can switch which version of Java runs by default. First, though, let’s see which version of Java we just installed:
~$ /usr/lib/jvm/java-6-sun/bin/java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Server VM (build 16.3-b01, mixed mode)
At the time of this writing, the most recent stable version of Java is Version 6 Update 21. According to my terminal output above, I just installed Version 6 Update 20. One update behind isn’t too bad, so I didn’t see any reason to download Java directly from Sun.Ok, how do we switch which version of Java runs by default? Do this:
~$ sudo update-java-alternatives -l
This should show you the available versions of Java. Now, to switch the default to Sun Java, do this:~$ sudo update-java-alternatives -s java-6-sun
java-6-openjdk 1061 /usr/lib/jvm/java-6-openjdk
java-6-sun 63 /usr/lib/jvm/java-6-sun
Great! Now we have a recent version of Sun Java installed and ready to use. The next step is to get Eclipse.Install Eclipse
Don’t download eclipse from the Ubuntu repository. If you already have, uninstall it. Instead, get the most up-to-date version of eclipse at the Eclipse download page. I chose to download Eclipse Classic 3.6.1 as opposed to the tailored versions. From my understanding, the only differences are which plugins come with the download. Here’s how to extract the download and create a startup script for it that’s inside the system path:$ cd /opt $ sudo tar xzf /home/greeenguru/Downloads/eclipse-SDK-3.6.1-linux-gtk.tar.gz $ sudo touch /usr/bin/eclipse $ sudo chmod +x /usr/bin/eclipse $ sudo gedit /usr/bin/eclipseNow edit the executable file you just created to contain the following BASH startup script:
#!/bin/sh
export ECLIPSE_HOME="/opt/eclipse"
# Now run eclipse with the argument list $*
$ECLIPSE_HOME/eclipse $*
Just use the GUI to do this. It’s easier and more reliable. Right-click on your applications menu, choose Edit Menu, go to your Programming menu, and hit the New Item button. This way, your icon set might even have a default icon for you automatically, and you don’t have to worry about if the method below will work or not.
~$sudo gedit /usr/share/applications/eclipse.desktop
Now go to your Applications Menu, click on Eclipse, and make sure it works.[Desktop Entry] Encoding=UTF-8 Name=Eclipse Comment=Program Some Stuff GenericName=Interactive Development Environment Exec=eclipse Terminal=false Type=Application Icon=/opt/eclipse/icon.xpm Categories=GNOME;Application;Development; StartupNotify=true
Install the C/C++ Development Toolkit (CDT) Eclipse Plugin
Now that you have Eclipse up and running, let’s add C/C++ support via the CDT plugin. We can do this entirely from within Eclipse. Just go to Help → Install New Software…:Then click on the Add to add a software site to install from:
The CDT repository is located at http://download.eclipse.org/tools/cdt/releases/helios:
At first, I tried to just install all the available CDT options:
But after I received an error, I went back and deselected the Remote Launch package. I’m sure I don’t need all of these options, but I don’t know which ones I do need, so I just installed all of the rest as you can see below:
After making your choices, click Next. You will see an Install Details dialog containing all the software you selected to install (assuming you didn’t get an error). Just click Next. Finally, you’ll see a Review Licenses window. Just agree to the license agreement and your installation will begin:
Since Ubuntu already has g++, make, gcc, and gdb, installed and in the system path, you shouldn’t have any problem building C++ programs once CDT is finished installing. Just be sure to restart when prompted, then try it out. Go to Help → Cheat Sheets and find the Hello World application for C++. This will walk you through building a simple C++ executable.
Note: If you have problems after restarting Eclipse, exit and restart from the run dialog or terminal with the command eclipse -clean. This will clean the Eclipse cache and hopefully resolve some problems.
Install the PyDev Eclipse Plugin for Python Support
You can install PyDev for Python support completely from within Eclipse just as you did the CDT. Just follow the same steps as before (Help → Install New Software… and click Add), then add the PyDev repository, which is located at http://pydev.org/updatesI don’t use Django, so I just need the main package:
Finish the Install Wizard as you did with CDT and restart Eclipse when prompted. You now have support for Java, C/C++, and Python!
Note: If you have problems after restarting Eclipse, exit and restart from the run dialog or terminal with the command eclipse -clean. This will clean the Eclipse cache and hopefully resolve some problems.
Install The Qt Eclipse Integration Plugin
Qt Eclipse Integration is pretty cool if you’re going to be doing any C++ GUI development. You have to make sure you have CDT installed first, then download the package from the Qt Eclipse Integration Download Page. The rest of my instructions are basically taken from Qt’s Installation Instructions for Linux Systems.According to Qt’s website, the preferred method for installing their plugin is from outside Eclipse, so go ahead and close it first. Next, make sure you have the Qt4 Development Library installed:
$ sudo apt-get install libqt4-dev qt4-doc-html
Notice that I also installed the documentation. I usually create a launcher for the documentation I think I’ll use:Go to the location of your eclipse installation directory and extract the Qt plugin. For some reason the plugin has been archived to extract as eclipse → plugins → important stuff, so you need to be in the parent folder of your eclipse installation directory when you extract the plugin in order for everything to extract to the right place:
$ cd /opt $ sudo tar xzf /home/greeenguru/Downloads/qt-eclipse-integration-linux.x86-1.6.1.tar.gzThat’s it. Just launch Eclipse from the run dialog or terminal with the command eclipse -clean to start with a clean configuration. However, you’re not quite done because it still needs some configuring. You’ll need to know the version of Qt that you’re using, so do this to find out:
~$ qmake -version
QMake version 2.01a
Using Qt version 4.6.2 in /usr/lib
qmake came with the libqt4-dev package you just installed, and it is using Qt version 4.6.2 (on my system anyway). Now in Eclipse go to Window → Preferences and you should see the dialog below. Go to the Qt section as shown and Click the Add… button to add a new Qt version. This will tell Eclipse where to find the Qt version you plan to use.When you’ve finished with the dialog above, click Finish. Then click on the version you just added and click Default to make that the default Qt version:
Finally, click Apply and you should get the following dialog:
Click Yes to this dialog and then exit Preferences by clicking Ok. Now, you’re finished configuring Qt. To get started using it, go to Help → Cheat Sheets and select Qt Development. There should be an address book application walkthrough you can learn from. Here’s what my screen looked like halfway through the walkthrough. It works just like Qt Designer, but it’s running inside Eclipse.
Well that’s really it. Now you should be able to program in Java, Python, C/C++, and design Qt-based C++ GUI applications all from inside the same cross-platform IDE. Enjoy!