IDE Setup

From TUDOS-Wiki
Revision as of 14:36, 26 November 2014 by BjoernD (talk | contribs) (Emacs completion setup for L4Re)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search


If you want to use Eclipse to work on the ComplexLab, you need to tell Eclipse where the include files are located and provide them in the correct order.

To simplify that task, you can import this project-settings using File -> Import -> C/C++ Project Settings. Afterwards you need to rebuild the index at <Your project> -> Index -> Rebuild. Note that this settings are specific for the ComplexLab and the x86 architecture.

This is a work in progress, so don't expect it to be perfect :-)


KDevelop requires you to set up an index file using absolute paths. This file is called .kdev_include_paths and should reside in the root directory of your L4Re checkout. Mine looks like this:


VIM / YouCompleteMe

VIM's excellent YouCompleteMe plugin provides C/C++ completion and works for L4Re with some tweaks. You will need to define your own customization for YCM by putting a file in your l4/pkg directory. Start with a copy of the original file that ships with YCM (.vim/bundle/YouCompleteMe/cpp/ycm/

Set the flags array to contain a list of the L4Re compile flags that should be passed to Clang for compilation. You can get those flags by doing a

 $> make VERBOSE=1

for any of your L4Re packages and copying the flags from there.

The important part of looks like this for me:

flags = [
# THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won't know which
# language to use when compiling headers. So it will guess. Badly. So C++
# headers will be compiled as C headers. You don't want that so ALWAYS specify
# a "-std=<something>". 
# For a C project, you would set this to something like 'c99' instead of
# 'c++11'.
# ...and the same thing goes for the magic -x option which specifies the
# language that the files to be compiled are written in. This is mostly
# relevant for c++ headers.
# For a C project, you would set this to 'c' instead of 'c++'.
'-isystem /usr/lib/gcc/x86_64-linux-gnu/4.7/include',
'-isystem /usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed'

Emacs / Auto-Complete-Clang

As I have too much time on my hands I even have a working completion setup for Emacs. Here I am using autocomplete-clang-async. Then in .emacs:

(defun my-ac-cc-mode-setup ()
  (add-to-list 'load-path "~/.emacs.d/ac-clang-async")
  (require 'auto-complete-clang-async)
  (setq ac-clang-complete-executable "~/.emacs.d/ac-clang-async/clang-complete")
  (setq ac-sources '(ac-source-clang-async))

  (let ((bname (buffer-file-name)))
     ; L4Re-specific configuration
     ((string-match "l4/pkg" bname)
      (setq clang-include-dir-str "
      (setq clang-pre-flags '("-nostdinc" "-g" "-std=c++11" "-m32" "-DSYSTEM_x86_586_l4f"
                              "-DARCH-x86" "-DCPUTYPE_586" "-DL4API_l4f" "-D_GNU_SOURCE" "-D__L4"
                              "-fexceptions" "-fno-omit-frame-pointer" "-fno-strict-aliasing"))
      (setq clang-add-flags '("-isystem /usr/lib/gcc/x86_64-linux-gnu/4.9/include"
                              "-isystem /usr/lib/gcc/x86_64-linux-gnu/4.9/include-fixed" ))

     ; Everthing else (aka Linux programming)
    ((t) (setq clang-include-dir-str "
     (setq clang-pre-flags ())
     (setq clang-add-flags '("-x c++" "-g" "-std=c++11" "-msse4"))
  (setq clang-iflags
         (mapcar (lambda (item) (concat "-I" item))
                 (split-string clang-include-dir-str))
  (setq ac-clang-cflags (append clang-pre-flags clang-iflags clang-add-flags))

  (setq ac-clang-auto-save t)

(add-hook 'c-mode-common-hook 'my-ac-cc-mode-setup)
(add-hook 'c++-mode-hook 'my-ac-cc-mode-setup)