wiki:compile_all

Version 11 (modified by Sanahuja Guillaume, 6 years ago) ( diff )

--

Build system

NOTE: For Flair version <= 0.2.1, see this page.

Only Flair sources are provided. You need to compile everything by yourself to get development files, demos and tools.

Helper scripts

Some scripts are provided to help configuration and compilation of projects. Using it you can compile everything easily. They are included in flair-dev repository.

CMake & CodeLite

Flair uses CMake as project descriptor. One recommended IDE is CodeLite. The helper scripts will produce projects for CodeLite from CMakeLists.txt but you can adapt it to your favourite IDE.

Note that CodeLite CMake generator has been patched in robomap3 to better fit flair needs.

CMake tricks

All CMakeLists in flair use custom modules located in flair-dev. The 2 principal ones are:

  • FlairUseFile.cmake: used by demos/tools, it helps adding include dirs and libraries for programs using flair

A better explanation on how to use these modules can be found here.

Each installed toolchain have a toolchain.cmake file (for example /opt/robomap3/2.1.3/armv5te/toolchain.cmake) which defines everything needed by CMake to compile for a specific architecture.

Out of source build

The recommended usage is to build everything out of source, in order to keep your svn repositories clean. Helper script (flair_compile_all.sh) will build everything in $FLAIR_ROOT/flair-build directory.

One directory by architecture

cmake_codelite_outofsource.sh creates a folder for each supported architecture (ie by installed toolchain) in flair-build directory. For example:

  • build_armv7a_neon for armv7a-neon architecture (ardrone2, bebop, hds x8)
  • build_armv5e for armv5e architecture (mambo)
  • build_cortexa7thf_neon_vfpv4 for cortexa7thf-neon-vfpv4 architecture (raspberry pi)
  • build_core2_64 for core2_64 architecture (PC)

Note that there is also a symlink from build to build_core2_64.

Compile Flair libraries, tools and demos all together

To compile all Fl-AIR stuffs, you can execute the dedicated script:

$ $FLAIR_ROOT/flair-dev/scripts/flair_compile_all.sh

If it is the first time you execute this script, you must answer yes to the question Compile all from scratch. This will create every projects using cmake.

The script detects installed toolchains and compile everything for each supported architecture.

Results are the following:

  • flair libs headers installed in $FLAIR_ROOT/flair-dev/include
  • flair libs binaries installed in $FLAIR_ROOT/flair-bin/lib
  • flair tools binaries installed in $FLAIR_ROOT/flair-bin/tools/core2-64 (but launching scripts are in $FLAIR_ROOT/flair-bin/tools/scripts)
  • flair demos binaries installed in $FLAIR_ROOT/flair-bin/demos

For Heudiasyc users, additional stuffs are also installed:

  • flair hds libs headers installed in $FLAIR_ROOT/flair-hds/dev/include
  • flair hds libs binaries installed in $FLAIR_ROOT/flair-hds/bin/lib
  • flair hds demos binaries installed in $FLAIR_ROOT/flair-bin/demos

Recompile a particular project

NOTE: this is only for projects provided in flair-src and flair-hds repositories. For your own project go to next section

If you have already done the previous step (compile everything) and you want to just recompile and install a particular project (lib, demo or tool), do the following:

$ cd $FLAIR_ROOT/flair-build/build/project_path
$ make install

It will compile for x86_64 architecture. To compile for a different architecture, go to the corresponding directory, for example:

$ cd $FLAIR_ROOT/flair-build/build_armv5te/project_path
or
$ cd $FLAIR_ROOT/flair-build/build_armv7a_neon/project_path
or
$ cd $FLAIR_ROOT/flair-build/build_cortexa7thf_neon_vfpv4/project_path

project_path depends on what you are compiling:

  • FlairLibs/lib: a flair library (for example FlairLibs/FlairCore)
  • tools/tool: a flair tool (for example tools/FlairGCS)
  • demos/demo: a flair demo (for example demos/CircleFollower). Not that you can also have subfolders like demos/CircleFollower/simulator or demos/CircleFollower/uav if you want to compile just simulator or uav project

For Heudiasyc users project_path can also be the following:

  • flair-hds/FlairHdsLibs/lib: a flair hds library (for example flair-hds/FlairHdsLibs/FlairArdrone2)
  • flair-hds/demos/demo: a flair hds demo (for example flair-hds/demos/ApriltagFollower). Not that you can also have subfolders like flair-hds/demos/ApriltagFollower/simulator or flair-hds/demos/ApriltagFollower/uav if you want to compile just simulator or uav project

Compile your own project

NOTE: this is also works for projects provided in flair-src and flair-hds repositories.

Compilation with debug (optional)

If you have to debug surprising segfaults (you know what I mean, do you? :D ) you will need to compile your code in debug mode (see below). Then you'll have to activate the core dump generation (in each terminal) with

$ ulimit -c unlimited

To be sure that the kernel will generate those migthy core file you should issue this command

echo core > /proc/sys/kernel/core_pattern (en sudo)

Then when your program crashes, it will generate a "core" file. Use gdb with your binary as the first parameter (again, compiled in debug mode) and the core file as the second parameter (use your cross compiled gdb in case of cross development, arm-poky...-gdb for instance to debug an arm code from your PC). It should load your program symbols. Then the "bt" command will show the backtrace, which is the sequence of function calls that resulted in the crash, allowing you to know exactly where is the problem.

Full framework

If you want to debug the framework itself, you may find beneficial to compile the full framework in debug mode you need to edit the file

$ /opt/robomap3/<version>/<arch>/toochain.cmake

and add "-g -O0" to the CMAKE_CXX_FLAGS variable. As of this writing, and for an x86 architecture, the file to edit is "/opt/robomap3/2.1.3/core2-64/toolchain.cmake". Then you shall rebuild the whole framework with a call to flair_compile_all.

Flair based app

If you want to debug your flair based application code, but don't need to debug the framework itself, you need to edit the file

<app>/build/CMakeFiles/<app>.dir/flags.cmake

and add the command add_definitions("-g -O0").

Note: See TracWiki for help on using the wiki.