Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
4 contributors

Users who have contributed to this file

@SimonKagstrom @vladignatyev @brycefisher @asomers

Building Kcov

Installing dependencies

You need development headers and libraries for libstdc++, curl, elfutils and (optional) binutils and libiberty to build kcov. Note that elfutils is found in multiple variants, and at least in RH/Centos/Fedora you'll need elfutils-devel and not elfutils-libelf-devel.


pkg install binutils cmake elfutils python



  apt-get install binutils-dev libssl-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev

Fedora / Centos / RHEL

Install elfutils-libelf-devel libcurl-devel binutils-devel elfutils-devel

Mac OS X

brew install zlib bash cmake pkgconfig

  • OSX build instructions (see Issue #166 / Issue #357):

Create an empty build dir and do the following steps:

  cd <build-dir>
  cmake -G Xcode -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib <path/to/kcov/source/dir>
  xcodebuild -target kcov -configuration Release

The binary will be src/Release/kcov


Create an empty build dir and do the following steps:

cmake [options] <path/to/kcov/source/dir>
make install

Useful options include -DCMAKE_INSTALL_PREFIX= (installation prefix), -DCMAKE_BUILD_TYPE= and -DCMAKE_C_FLAGS=.

Basic example:

    cd /path/to/kcov/source/dir
    mkdir build
    cd build
    cmake ..
    make install

More advanced example:

    cd /path/to/kcov/source/dir
    mkdir build
    cd build
    cmake \
      -DCMAKE_C_FLAGS:STRING="-O3 -march=i686" \
      -DCMAKE_BUILD_TYPE=Release \
    make -j2 || exit 1
    make install DESTDIR=/tmp/kcov-build || exit 1

For further information refer to cmake documentation:


If you have elfutils installed, but cmake fails to find it, specify elfutils install prefix explicitly to cmake. Here is an example:

    cd kcov
    CMAKE_PREFIX_PATH=/opt/elfutils-dir/ \
    cmake .
    make install