Vous êtes sur la page 1sur 11

01/03/2011 Eclipse – C/C++ (CDT), Python (PyDe…

Greeen Notes
Computer and programming notes,
plus some of my software

Eclipse – C/C++ (CDT), Python (PyDev), and Qt (Qt4) Plugins Installation Tutorial for Ubuntu
10.04
Posted on September 28, 2010 by GreeenGuru

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!

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

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:

greeennotebook.com/…/eclipse-cc-cdt… 1/11
01/03/2011 Eclipse – C/C++ (CDT), Python (PyDe…

~$ /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/eclipse

Now 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 $*

Create a GNOME menu item for Eclipse:

~$ sudo gedit /usr/share/applications/eclipse.desktop

greeennotebook.com/…/eclipse-cc-cdt… 2/11
01/03/2011 Eclipse – C/C++ (CDT), Python (PyDe…
Here’s what to enter to create the menu item correctly:

[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

Now go to your Applications Menu, click on Eclipse, and make sure it works.

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:

greeennotebook.com/…/eclipse-cc-cdt… 3/11
01/03/2011 Eclipse – C/C++ (CDT), Python (PyDe…

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/updates

greeennotebook.com/…/eclipse-cc-cdt… 4/11
01/03/2011 Eclipse – C/C++ (CDT), Python (PyDe…

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.

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

greeennotebook.com/…/eclipse-cc-cdt… 5/11
01/03/2011 Eclipse – C/C++ (CDT), Python (PyDe…
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.gz

That’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:

greeennotebook.com/…/eclipse-cc-cdt… 6/11
01/03/2011 Eclipse – C/C++ (CDT), Python (PyDe…

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!

greeennotebook.com/…/eclipse-cc-cdt… 7/11
01/03/2011 Eclipse – C/C++ (CDT), Python (PyDe…
About GreeenGuru
Computer Enthusiast
View all posts by GreeenGuru →

This entry was posted in Ubuntu and tagged C++, Eclipse, PyDev, Python, Qt, Ubuntu. Bookmark the permalink.

15 Responses to Eclipse – C/C++ (CDT), Python (PyDev), and Qt (Qt4) Plugins Installation Tutorial
for Ubuntu 10.04

Pingback: creating C++ GUI in eclipse

eric says:
October 24, 2010 at 2:29 am

hey!!
thank you for such a wonderfull tutorial and it was very helpful! but i have a small problem: when i was trying to install java
through the terminal the OK button was not active after reading the software disclamairre!! all it said that it was still
configuring java!!
i was wondering where i went wrong!!!

GreeenGuru says:
October 25, 2010 at 8:11 am

eric,

I’m glad you found this helpful. I’m not sure why you are having that problem, but I suppose in your shoes I would try
installing the same packages via the Synaptic Package Manager, and I’d probably change my screen resolution first (max it
out). That trick has worked for me before in other applications. Unfortunately, I can’t give you specific advice with any
certainty. Good luck!

vasilis says:
October 26, 2010 at 8:17 am

Hi guru!

Congrats for this tutorial. Believe me, looking for a complete guide on the net, this is by far the most updated that I found.
I used this guide for the installation of the android SDK (via eclipse). Please, update your guide, including the android SDK
installation (site:https://dl-ssl.google.com/android/eclipse/). Trying to install it, I found the following errors (please delete it,
if it is too large):
Cannot complete the install because of a conflicting dependency.

Software being installed: Android Development Tools 0.9.9.v201009221407-60953 (com.android.ide.eclipse.adt.feature.group

0.9.9.v201009221407-60953)

Software currently installed: Shared profile 1.0.0.1284044171320 (SharedProfile_SDKProfile 1.0.0.1284044171320)

Only one of the following can be installed at once:

International Components for Unicode for Java (ICU4J) 4.2.1.v20100412 (com.ibm.icu 4.2.1.v20100412)

International Components for Unicode for Java (ICU4J) 4.0.1.v20090822 (com.ibm.icu 4.0.1.v20090822)

International Components for Unicode for Java (ICU4J) 4.0.1.v20090415 (com.ibm.icu 4.0.1.v20090415)

Cannot satisfy dependency:

From: Shared profile 1.0.0.1284044171320 (SharedProfile_SDKProfile 1.0.0.1284044171320)

To: com.ibm.icu [4.2.1.v20100412]

Cannot satisfy dependency:

From: Android Development Tools 0.9.9.v201009221407-60953 (com.android.ide.eclipse.adt.feature.group 0.9.9.v201009221407-

60953)

greeennotebook.com/…/eclipse-cc-cdt… 8/11
01/03/2011 Eclipse – C/C++ (CDT), Python (PyDe…
To: org.eclipse.wst.sse.ui 0.0.0

Cannot satisfy dependency:

From: Java EMF Model Utilities 2.0.200.v200905140200 (org.eclipse.jem.util 2.0.200.v200905140200)

To: bundle com.ibm.icu [3.8.1.1,4.1.0)

Cannot satisfy dependency:

From: Java EMF Model Utilities 2.0.201.v201001252130 (org.eclipse.jem.util 2.0.201.v201001252130)


To: bundle com.ibm.icu [3.8.1.1,4.1.0)

Cannot satisfy dependency:

From: Common Frameworks 1.1.300.v200904160730 (org.eclipse.wst.common.frameworks 1.1.300.v200904160730)

To: bundle org.eclipse.jem.util [2.0.100,3.0.0)

Cannot satisfy dependency:

From: Structured Source Editor 1.1.101.v200908261807 (org.eclipse.wst.sse.ui 1.1.101.v200908261807)

To: bundle org.eclipse.wst.validation [1.2.0,1.3.0)

Cannot satisfy dependency:

From: Structured Source Editor 1.1.102.v200910200227 (org.eclipse.wst.sse.ui 1.1.102.v200910200227)

To: bundle org.eclipse.wst.validation [1.2.0,1.3.0)

Cannot satisfy dependency:

From: Validation Framework 1.2.102.v200905201610 (org.eclipse.wst.validation 1.2.102.v200905201610)

To: bundle org.eclipse.wst.common.frameworks [1.1.200,2.0.0)

Cannot satisfy dependency:

From: Validation Framework 1.2.104.v200911120201 (org.eclipse.wst.validation 1.2.104.v200911120201)

To: bundle org.eclipse.wst.common.frameworks [1.1.200,2.0.0)

Thank you and congrats again!

vasilis says:
October 26, 2010 at 10:13 am

Hi again,

I found the solution for this problem so please delete the previous (giant) error message. The android SDK must be installed
as root. There is a bug here… After the installation of the SDK as root, when you log as user, the shortcut of Eclipse in the
application menu is disappeared and you must repeat the steps for the creation of its shortcut in the GNOME menu.

Thank you!

Shuda Li says:
December 6, 2010 at 9:20 pm

Hi 谢谢!

It’s a great tutorial! Appreciated!

markovchain says:
December 15, 2010 at 7:48 pm

Nice tutorial. One question. Why not download eclipse from the Ubuntu repository?

GreeenGuru says:
December 16, 2010 at 4:24 pm

Although I’m usually happy with the slightly out-of-date software in the Ubuntu repository, sometimes I want/need the
current release. As I write this, the current Eclipse version available from the repo is 3.5.2, and the latest Eclipse release is

greeennotebook.com/…/eclipse-cc-cdt… 9/11
01/03/2011 Eclipse – C/C++ (CDT), Python (PyDe…
3.6.1 (Helios). Helios offers several improvements.

Marco Esteves says:


January 15, 2011 at 11:47 pm

It seems a good tutorial, but dind’t work with me.


When I add the cdt repository, i don’t get anything and gives this message error
“Unable to read repository at http://download.eclipse.org/tools/cdt/releases/helios/content.xml.”

Any help? :)

GreeenGuru says:
January 16, 2011 at 1:28 am

Marco,

Google shows you’re not the only one with that error, but I don’t know why you’re getting it. You didn’t actually enter that
URL did you? It should have just been http://download.eclipse.org/tools/cdt/releases/helios

Sorry I’m not much help.

lvilla says:
January 31, 2011 at 11:40 am

Thank you for an excellent tutorial. Just installed everything indicated without a hitch. Time to start programming new
projects!

martin says:
February 6, 2011 at 7:18 am

If anyone had same issue as me – install everything up to the qt integration copy into the eclipse folder and nothing for QT
shows up.
I started eclipse with debug flag and observed exception that in the plugin section is missing id tag. I went through all the qt
plugins (either jar-ed or not) and removed all plugin.xml files which was containing just empty plugin tag. And it started and
so far i have tested (not much yet) it seems to work. I just started going through the cheat shee tutorial…
br
Martin.

martin says:
February 6, 2011 at 7:20 am

PS: having 64bit ubuntu + sun java, eclipse helios:


Eclipse IDE for C/C++ Developers

Version: Helios Service Release 1


Build id: 20100917-0705

em jjunju says:
February 12, 2011 at 9:25 am

hei this happens to me

usr/bin/eclipse: 6: /opt/eclipse/eclipse: Permission denied

greeennotebook.com/…/eclipse-cc-cdt… 10/11
01/03/2011 Eclipse – C/C++ (CDT), Python (PyDe…
after

Create a GNOME menu item for Eclipse:

~$ sudo gedit /usr/share/applications/eclipse.desktop

Here’s what to enter to create the menu item correctly:

[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

Now go to your Applications Menu, click on Eclipse, and make sure it works.

Robke says:
February 23, 2011 at 2:28 am

Nice tutorial, got me through all the hassle in a giffy! Thanks! Kudos for you ;-)

Greeen Notes
Proudly powered by WordPress.

greeennotebook.com/…/eclipse-cc-cdt… 11/11

Vous aimerez peut-être aussi