Use Eclipse to develop GATB-Core softwares

This article explains how to install and configure the Eclipse c++ IDE to work on GATB-Core based projects, either GATB-Core library or GATB-Tools.

Preliminary comment

There is no requirement to use Eclipse to develop source code; you can use whatever system you prefer.

The purpose of this article is just to provide newbies with a convenient way to deploy an open-source c++ integrated development framework to work on GATB-Core codes.

Taken from Eclipse/CDT documentation, Eclipse C++ features include: support for project creation and managed build for various toolchains, standard make build, source navigation, various source knowledge tools, such as type hierarchy, call graph, include browser, macro definition browser, code editor with syntax highlighting, folding and hyperlink navigation, source code refactoring and code generation, visual debugging tools, including memory, registers, and disassembly viewers.

Apple’s MacOSX developers: you should consider to use Xcode.

Requirements

To handle the development cycle of GATB-Core projects, you need:

  • a 64-bit computer running Linux (e.g. Debian, Ubuntu, Fedora, CentOS) or Mac OSX (10.9+)
  • CMake 3.1.0 or later
  • a c++/11 source code compiler:
  • gdb, the GNU Project Debugger

Install Eclipse

Download Eclipse Mars c++ IDE; choose your platform on the right side of that page.

We ask you to install Eclipse Mars, since this document was established using that release of the IDE… you may choose to work with another release, but at your own risk (i.e. may work, but not tested).

Then, you can check that you can indeed compile c++ code by following these instructions; have a look at the second part: “Running a simple Hello World c++ software”. Mac OSX users: first part of this page is dedicated to the installation of XCode… if needed!

Install Eclipse CDT

  • Start Eclipse if not already done
  • Go to menu “Help”, then select “Install new softwares”
  • Use that URL to tell Eclipse Mars where to find CDT: https://www.eclipse.org/cdt/downloads.php
  • Then choose to only install “CDT Main”
  • Restart Eclipse after installation has completed

Prepare GATB-Core source code

Note: what is written here for GATB-Core also applies for a GATB-Tool project.

Standard GATB-Core development cycle

If you have already worked with GATB source code, you may have done this:

cd <some-directory>

git clone https://github.com/GATB/gatb-core.git

cd gatb-core/gatb-core

mkdir build ; cd build ; cmake .. ; make -j4

For newbies to GATB-Core development cycle, this is the standard way of working:

  • cmake  and make are used to compile GATB-Core source code
  • the ‘build’ directory is located within the source code

When working with CMake and Eclipse: “YOU CAN NOT PROCEED THIS WAY ANYMORE !

Eclipse-based GATB-Core development cycle

In order to work with CMake and Eclipse, you have to prepare two separated folders:

  • one to host the GATB-Core source code
  • one to host the build directory, which contains CMake generated files
    This build directory MUST NOT be located within the GATB-Core source code.

So, for the rest of this manual, we setup these two folders (adapt to your needs and remember: DO NOT place the build directory within GATB-Core source directory):

<source-directory>: ~/devel/git

<build-directory>: ~/devel/build

Now, get a copy of the GATB-Core source code:

cd ~/devel/git

git clone https://github.com/GATB/gatb-core.git
WARNING: read-only repository. If you intend to commit code
(e.g. Inria developers), clone from Inria Forge.

Finally, build CMake files:

cd ~/devel/build

cmake -G"Eclipse CDT4 - Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug ~/devel/git/gatb-core/gatb-core

By now: DO NOT compile gatb-core. We are going to that in Eclipse.

Import GATB-Core into Eclipse

This is very, very easy:

  • go to menu “File”
  • select “Import…”
  • select “General/Existing Projects into Workspace”
  • choose to import “~/devel/build”; do not check “Copy projects into workspace”
  • click on [Import]

The Eclipse “Project Explorer” now contains a project called: “gatb-core@build”.

Now, compile GATB-Core for the first time:

  • go to menu “Project”
  • select “Build all”

or (in case you have many projects within Eclipse):

  • right click on “gatb-core@build” in the “Project Explorer”
  • select “Build project”

From here, you should have everything to work on and compile c++ codes.

Tips and tricks

We have two folders of interest within the “Project Explorer” of Eclipse (left side panel):

  • [Binaries]: standard GATB-Core binaries such as dbgh5, etc.
  • [Source directory]: a link to ~/devel/git/gatb-core/gatb-core… which means: “This IS the place from where you edit GATB-Core code, and nowhere else!”.

Compile GATB-Core code snippets

As you may know, GATB-Core contains a set of code snippets that can be used to learn coding with the library. By default, Eclipse does not compile them. So, let us say that we would like to compile “kmer3.cpp” snippet. Proceed as follows:

  • right click on the project header “gatb-core@build” within the Eclipse “Project Explorer”
  • a popup menu appears where you select “Make Target -> Build”
  • a dialog box opens: choose “build – kmer3”
  • after a few seconds, “kmer3” binary will be displayed under the [Binaries] directory
  • right click on “[Binaries] -> kmer3” and select “Run as -> Local c/c++ application”

Another quick way to compile a particular code snippet:

  • unroll the [Targets] directory within the “Project Explorer” or “gatb-core@build”
  • all code snippets are displayed
  • right click on one of them, then select “Make targets…” -> “Build…”

Debugging GATB-Core code

Eclipse c/c++ IDE is designed to use GDB (the GNU Project Debugger) on Unix systems.

Linux users

gdb is usually installed, so there is nothing to do. Eclipse will be able to find GDB as soon as you start to run a GATB-Core based code using Eclipse Debug Mode. If not… well, we invite you to use your favourite web search engine to find what is wrong between Eclipse and GDB on YOUR Linux flavour.

MacOSX users

As far as we know, GDB is not anymore provided with XCode.

So, let us check that. Open a terminal, then

gdb --version

Command not found? So, bad day: you have to install GDB.

Install GDB using howebrew

Open a terminal, then:

brew install gdb

It is worth noting that this command may not work depending on your OSX release. In such a case, do not worry, and jump to next section.

Install GDB from its source code

The ultimate solution remains to install GDB by compiling its source code. Of course, the basic requirement: having XCode installed.

Proceed as follows:

  • go to http://ftpmirror.gnu.org/gdb
  • download: gdb-7.10.tar.gz (this is the one we have compiled and successfully use with Eclipse Mars)
  • uncompress and unarchive gdb-7.10.tar.gz
  • cd gdb-7.10
  • ./configure
  • make
  • make install
  • gdb –version
    GNU gdb (GDB) 7.10
    Copyright (C) 2015 Free Software Foundation, Inc. …/…

Now, the tricky part consist in digitally signing the “gdb” binary. Otherwise, Eclipse will refuse to use it. For that part, we found on the web a very concise help, right here. Please, follow it before going to the next (and final) step.

Provide Eclipse with GDB

By default, gdb is compiled and installed in “/usr/local/bin”.

Switch to Eclipse:

  • from menu Eclipse, select “Preferences…”
  • follow that path: C++ -> Debug -> GDB
  • within the field “GDB debugger”, enter the string: /usr/local/bin/gdb

Well done: gdb is now available for Eclipse debugging purpose on your Mac.

Resources

 

Comments are closed.