Skip to content

Working With Eclipse CDT

slivne edited this page Jul 1, 2014 · 10 revisions

Installation

Fedora

Eclipse CDT is provided by fedora packages, so simply: yum install eclipse-cdt

Other distribution

You can always install eclipse CDT following instructions from https://www.eclipse.org/cdt/.

Increase heap size

Eclipse uses a Java virtual machine started with a fixed upper limit on its heap size, defined in /etc/eclipse.ini. This limit is often not large enough for indexing the OSv project. It's recommended to edit /etc/eclipse.ini and make sure the "-Xmx" setting is at least 1 GB.

Creating OSv Project.

After installing eclipse-cdt, you'll need to create OSv project to work with. Eclipse support some built-in project templates, but since we already have OSv downloaded from git, we do not want to have things messed up by eclipse.

So under File -> New -> Project, select C/C++ folder and than select "Makefile Project with Existing Code".

Click Next.

Give a project name and select the place where OSv code was downloaded.

You can now click Finish.

Configuring OSv project.

OSv has some particularities that eclipse do not understand as default, such as:

  • It does have it's own libc/stdc++/libboost implementation
  • Its' a Kernel
  • It's c++11
  • It has a lot of includes paths that preprocessor should be awere of.

Unfortunately there is no magic configuration file that address all of this, so some manual configuration is needed.

Configure include paths and defines to OSv

Project -> Properties -> C/C++ General -> Preprocessor Includes -> GNU C++ -> CDT User Setting Entries -> Add a "Preprocessor Macro"; Name: no-highlight __GXX_EXPERIMENTAL_CXX0X__ value: 1

Project -> Properties -> C/C++ General -> Preprocessor Includes -> GNU C++ -> CDT User Setting Entries -> Add a “Include Directory”, in “Filesystem”, “/usr/include”

Configure g++ special arguments

To use OSv provided libs and includes, and to work correctly with c++11, we need some more tweaks. So go to:

Project -> Properties -> C/C++ General -> Preprocessor Includes

Under Provides tab, select CDT GCC Built-in Compiler Settings and uncheck "Use global provider shared between projects". Use the following command:

${COMMAND} -E -P -v -dD "${INPUTS}" -std=c++11 -include /YOUR_PATH_TO_OSV_SOURCE/include/api/stdalign.h -nostdlib -nostdinc -nostdinc++

do not forget to replace YOUR_PATH_TO_OSV_SOURCE

Configure eclipse indexer

This will prevent indexer to guess things in a wrong way:

Project -> Properties -> C/C++ General -> Indexer

Uncheck: "Index source files not included in the build" and "Allow heuristic resolution of includes'.

Configure coding style

To make OSv's code formatter conform to OSv's coding style, go to Project -> Properties -> C/C++ General -> Formatter, Set "Enable project specific settings", choose the K&R formatter and then click on the "Edit..." button to edit the formatter, choose a new name (e.g., "OSV") and in the "Indentation" setting choose "spaces only" as a tab policy.

Clone this wiki locally