< Projects‎ | Edu‎ | KStars
Revision as of 14:13, 11 June 2017 by Ckertesz (talk | contribs)

Projects/Edu/KStars/C++ developer tools with KStars on Linux

This page describes how to use open-source C++ tools to hunt down memory errors and improve the code quality.


Official homepage: https://ccache.samba.org

CCache is a useful tool to cache the compiled object files to avoid recompilation of the same source files. A typical use case is changing git branches when some include files are modified. By default, the compiler would recompile the affected source files after each branch checkout. With CCache, the build system can get the already-compiled object file from a local cache on the disk if available.

Install CCache on Ubuntu Linux:

  sudo apt-get install ccache

Add the -DCCACHE_SUPPORT=ON to the CMake flags to enable this feature. For example:


You can build KStars after these steps normally, CMake will put the compiler invocation after the ccache command and the object files will be saved to the local cache when a make command is executed.

Clang Format

Official homepage: https://clang.llvm.org/docs/ClangFormat.html

Clang Format can indent the source codes with a defined style. The config file (.clang-format) is in the root of the KStars Git repository. The clang format can be installed easily in Ubuntu Linux from the LLVM repositories (http://apt.llvm.org/):

  sudo apt-get install clang-format-5.0

The current bleeding-edge Clang Format does not support value indentation (style option: AlignConsecutiveMacros) after #define as of now (June 2017), therefore, a patched package is uploaded to this wiki page which contains the "define patch" from https://reviews.llvm.org/D28462. Unfortunately, the package file is zipped because this wiki does not support to upload .deb files directly: File:Clang-format-package.zip.

When clang-format is installed, a cmake flag (-DFORMAT_CODE=ON) is needed to enable Clang Format support. For example:

  cmake . -DFORMAT_CODE=ON

To format the code, a make command must be executed:

  make clang-format

This page was last edited on 30 October 2017, at 11:07. Content is available under Creative Commons License SA 4.0 unless otherwise noted.