SELinux basics

I recently came in touch with SELinux when I had to write/extend a policy for a commercial app. This post is some kind of notepad/cheatsheet I created while learning the topic. The aim is to document the concepts and commands which are necessary in order to be able to understand the basics and modify/adjust an existing SELinux policy.
→ Read More

distcc reduced compilation times to less than a half!

distcc is a program to distribute compilation of C, C++, Objective C or Objective C++ code across several machines on a network. Just evaluated distcc for building a ~1,4 Mio lines of code C++ code base on Linux with GCC. My local machine is already quite powerful. I usually build on 8 cores simultaneously (ninja -j8) with some quad-core Intel i7 and a quite fast SSD. A full build takes ~26 minutes.
→ Read More

gprof, Valgrind and gperftools - an evaluation of some tools for application level CPU profiling on Linux

In this post I give an overview of my evaluation of three different CPU profiling tools: gperftools, Valgrind and gprof. I evaluated the three tools on usage, functionality, accuracy and runtime overhead. The usage of the different profilers is demonstrated with the small demo program cpuload, available via my github repository gklingler/cpuProfilingDemo. The intent of cpuload.cpp is just to generate some CPU load - it does nothing useful. The bash scripts in the same repo (which are also listed below) show how to compile/link the cpuload.
→ Read More

A simple, customized logger, based on Boost.Log v2

Todays applications grow rapidly, complexity increases and finding bugs becomes more and more difficult. Especially for multi threaded applications, for applications that heavily depend on asynchronous external events or for applications that you don’t have local access to, an appropriate logging facility is invaluable for tracking down bugs. Boost.Log (v2) is a powerful C++ library that provides a simple way to integrate an extensible and performant logging facility in your application.
→ Read More

Creating and using shared libraries with different compilers on different operating systems

If you want to make your C/C++ project portable between operating systems and compilers, there are some things to consider. In this article I focus on shared libraries and give a practical overview on how to create and use shared libraries with various compilers on various operating systems, with the goal of portable source code and a unified build process. “A shared library or shared object is a file that is shared by executable files and further shared objects files.
→ Read More

How docker replaced my virtual machines and chroots

In one of my earlier posts I showed you why and how I use chroots for software development. In situations were the isolation of a chroot is not enough, I sometimes also used virtual machines. Both solutions have its pros and cons: A chroot is quite easy to setup and access with no virtualization overhead and you get native host performance. Virtualization offers very good isolation and some nice features e.
→ Read More

Playing around with libclang -> reverse engineering UML class diagrams

libclang is a stable, high level C interface to Clang - a compiler for C/C++ family programming languages based on LLVM. I recently played around with the python bindings to libclang and created a small tool called CodeDependencyVisualizer. This tool is intended for reverse engineering UML class diagrams out of existing C++ code. It can generate class diagrams with inheritances and associations. If class X is derived from class Y, a closed arrow is drawn from X to Y (inheritance).
→ Read More

Open source tools to examine and adjust include dependencies

In my previous post I wrote about include dependencies in general - why they matter and how to keep them at a minimum. In this article I’ll give a quick overview about the tools I evaluated and used to examine and adjust include dependencies of a large C++ project. I’ll cover some useful gcc compiler options, doxygen, cinclude2dot and the powerful include-what-you-use. GCC compiler options GCC provides some helpful options to determine/analyze include dependencies.
→ Read More

Why you should care about include dependencies in C/C++ and how to keep them at a minimum

When we think of dependencies, we usually think of “logical dependencies” at first: logical relations between classes, functions etc. Object oriented design, generic programming, encapsulation, design patterns are aimed to cut this “logical dependencies”. But there are also compile time dependencies - dependencies between files and libraries at compile time. This article is on include dependencies in C/C++ what are a sort of compile time dependencies. This dependencies have a huge impact on building, refactoring, testing and on the structure of your software.
→ Read More

Good enough is just right

When we develop a piece of software or functionality the following is true in many cases: It does not need to be super performant, it does not need to be robust to handle every imaginable error or flexible and generic to meet any future need. The test coverage does not need to be 100% and the code does not need to be perfect. Nevertheless, as developers we are often tempted to do things that probably nobody needs, like adding “super cool features”, refactor code just for the sake of perfection or optimize performance without any need.
→ Read More

Howto get hardware accelerated OpenGL support in Docker

I recently played around with Docker and tried to get OpenGL with hardware acceleration/direct rendering (DRI) to work. This was no big deal, but there are some things that must be considered and I want to share with you: The graphics driver in the docker container must be the same as on the host system. The X server on the host must permit connections from the docker container (this is what xhost + in run.
→ Read More

Why I wouldn't use a dynamically typed language for large applications

Currently I’m developing for and maintaining a large code base that’s a mix of C++ and Python code. In this article I write about my experience about the type systems of statically typed C++ and dynamically typed Python, especially about the situations where I miss the explicit type information in dynamically typed languages. I use Python as synonym for dynamically typed languages because my experiences with python should also apply for other dynamically typed languages.
→ Read More

How to use a chroot-jail for software development

In this tutorial I show you how you can easily setup and use a chroot-jail on Linux, and explain why this can be especially useful for software development. My main operating system is Arch Linux - I really like it because of it’s simplicity, flexibility and always up to date packages because of it’s rolling release style. A disadvantage of a rolling release style (for software development) is that the system is quite “volatile”: Major packet update can happen every time you update your system or just certain packages.
→ Read More

A QT Widget for Ogre3d

I recently played around with integrating Ogre3d into a QT5 Application. There are various resources about integrating Ogre3d and QT on the net, but for me non of them worked out of the box with recent QT5 and Ogre3d on Linux. Therefore i decided to publish my working implementation of an Ogre3d Qt widget that works on my up to date ArchLinux with Qt 5.2 and Ogre 1.9.0. You can find the sources on github.
→ Read More

Implementing undo/redo with the Command Pattern

This article is about implementing undo/redo functionality by utilizing the command pattern and assumes you know how the command pattern works (for a refresher on the command pattern you might take a look at this). To summarize, the command pattern is about representing and encapsulating all information that is needed to execute an action at a later time. Usually a command is an object that provides an interface execute(), which wraps the execution of the desired action.
→ Read More