How to use Eclipse with Hyrax Source Code
This presents one way to set up Eclipse to build, edit, debug, etc., the Hyrax source code. It's based on our previous how to documents, but is updated for (and maybe specific to) OSX 10.10, Eclipse 4.4 (Luna) and CDT 8.5. There are many things about Eclipse that can be pretty obscure, not the least of which is that Eclipse & CDT are not really 'just Eclipse' but may have specific configuration nuances. This is almost certainly not the only way to set this tool up to build the Hyrax code, just one way.
The set up assumes that you have already cloned the hyrax repo from GitHub (https://github.com/opendap/hyrax.git) and have run source spath.sh and ./hyrax_clone.sh so that the $PATH and $prefix environment variables are set and the libdap, bes and olfs repos have all been cloned. For most development, it's a good idea to clone hyrax-dependencies too.
The git perspective
What I've done to make projects that use the existing C++ code repos cloned from GitHub was to first use the git perspective to add the repo to Eclipse.
Switch to the git perspective using either the icon/toll-bar item on the right side of the main window or by going to the Window -> Open Perspective menu item.
Once the Eclipse window is showing the git perspective, you'll see something like the following:
Use the Add existing git repository icon to add an existing git repo.
The result looks like:
Make the projects
Follow theses steps to make a new project using the repo you just added to the git perspective.
- Import Projects
- New Project
- Use the New Project Wizard
- Existing Code Makefile
- Setup the Project
- Switch to C++ Perspective
- The New project
General Eclipse configurations
These are not specific to our project, but they are very useful and somewhat hard to sort out.
- How to set up PATH so the CDT build (which uses an external program) reads from the PATH you want instead of the default PATH
- How to get the editor in CDT to save before building code
- How to configure builds using an existing Makefile
- Editor tweaks:
- GDB on OS/X 10.9 and 10.10 is broken WRT shared object libraries (i.e., BES modules).
- Build GDB 7.8.x (other versions might work, but the default 6.x that comes with OS/X won't). To do this I had to sudo cp /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/machine/setjmp.h /usr/include/machine/ because while setjmp.h is present, there's nothing in <machine/setjmp.h> on 10.10 (and maybe 10.9, too). This may also explain the homebrew install fail on gdb, but I don't know. I also used export CC=gcc before running ./configure for gdb, but I doubt that made any difference in hindsight. Regardless, get a modern GDB built and installed.
- Follow this advice on setup with eclipse: http://ntraft.com/installing-gdb-on-os-x-mavericks/. NB: since PATH is already configured to have /usr/local/bin before the other stuff, the part about setting C/C++ -> Debug -> GDB to /usr/local/bin/gdb may be moot, but I did it all the same. The example shows the preferences window from a version of eclipse earlier than 4.4, which I am using.
- GDB and libtool: But GDB won't debug programs built with shared libs (dylibs on OS/X), responding with this message: "hell": not in executable format: File format not recognized for the program hell that's linked using libtool. Nice. The work-around is to use libtool --mode=execute gdb hell and maybe to set GDB to be libtool --mode=execute gdb although I have not tried the later.
- Now set up Eclipse: