Working with Eclipse under Windows
This is a crash course on using the open-source Eclipse
environment under Windows. It assumes a reader who
- wants to develop in C++ or for Blackberry, not straight Java
- is familiar with some Windows IDE, like a Visual Studio
- is not well-versed in Eclipse
Installation
The modern installation of Eclipse for C++ is relatively trivial, just use
the project Europa:
http://www.eclipse.org/downloads/moreinfo/c.php. See the Gotchas section for
minor tricks if things do not work out smoothly.
At the very least, the following packages need to be installed before Eclipse
- JRE from Sun
- Cygwin gcc/gdb from
http://www.cygwin.com/setup.exe . Select fast hosts for installation (*.gov
and kernel.org work well for me in the US), install stuff from Base and Devel sections.
Install Cygwin into a directory that does not contain spaces in
the name (\cygw works for me). Add this directory to PATH environment
variable - otherwise Eclipse will not find the tools.
Gotchas
The following is a list of minor problems (but major annoyances) that I have
encountered using Eclipse:
- Linker is unable to locate "WinMain@16". Solution is truly magical:
Change your main() function return value type to "int"
☺.
- GDB session cannot be established. Solution: Add c:\cygw\bin to PATH
in Windows.
- Eclipse cannot locate the source code. Solution: Add path mapping.
- Error message: *** target pattern contains no `%' is caused by a totally
braindamaged "fix" (excluding colons from pathnames for no other apparent
reason but the maintainer's dislike of Microsoft) in the recent Cygwin make
code. Solution: Replace the broken Cygwin file with a precompiled older
version
www.cmake.org/files/cygwin/make.exe instead.
Perspectives
All IDEs use multiple window configurations for different tasks, like editing
and debugging. In Eclipse, this process is made explicit via "perspectives" -
stored window configuration layouts. Eclipse likes to ask questions if it is OK
to change to a new perspective - in my experience, answer shall always be "yes".
The perspectives can be switched via a selector in the top right corner of the
IDE. So, if you are wondering where all your editing screens have gone after a
debugging session, don't worry - they are only a click away
☺.
Managing Projects
An idea of a project in Eclipse is quite different from
other IDEs. For example, it prefers the source files to be in the directory tree
maintained by Eclipse. Unfortunately, the C/C++ projects apparently go somewhat against the grain of
"sea of classes" in Java and therefore are hard to graft onto primarily
Java-oriented culture of core Eclipse developers. Some tips:
- Adding existing source files from non-Eclipse directories:
You can add files or folder from any location using links. To add a folder,
just right-click on your project->New->Folder, click on the advanced button
on the bottom, enable "Link to folder in the filesystem" and select the
folder you want to add. If you want to add just a file, right-click your
project->New->File ..., etc. The files/folders you added this way will be
marked by a little arrow (like windows shortcuts).
- Importing a makefile:
- Create a C - Makefile project (assuming the working dir of the
make is the project root folder)
- Change the project properties:
- Go to the C/C++ Build - Builder settings and uncheck "use
default build command"
- Add the command line (without the target to build) that
calls your make, e.g. c:\make\make -f makefile.mak -k
- Go to the Behaviour tab and add your targets for running
an incremental build, clean build and compile build (make sure
"Build (Incremental Build)" is checked. Otherwise the build cannot
be started at all.
- If everything is configured properly you can now run the make by
executing the menu entry Project -> Build Project
- Adding a library appears to be only possible via the
project properties
- Adding object files can only be done via "Other
objects" in Linker Build settings
Developing with Eclipse for BlackBerry
Setup:
- Download the "Full Installer" from
http://na.blackberry.com/eng/developers/javaappdev/javaeclipseplug.jsp
- Follow the video,
http://www.blackberry.com/DevMediaLibrary/view.do?name=eclipseJDE
- If, contrary to the video, the only non-grayed item under "Blackberry"
will be "Install signature keys":
- Don't try to obtain and install the keys - you most likely do not
need them
- Instead, create a Blackberry project
(File->New->Project->Blackberry)
- Now the things will magically start to work