LibrePCB Developers Documentation
Building LibrePCB

This page is aimed both at developers as well as packagers. If you're a packager and have any question regarding the LibrePCB build system, please join our chat or forum!

Building with Qt Creator

If you want to contribute a new feature or a bugfix to LibrePCB, the best way is to use Qt Creator. To get started, simply open the top-level CMakeLists.txt file with Qt Creator.

Configuring the Desktop Kit

When opening a project in Qt Creator for the first time, you need to configure the Desktop kit:

qtcreator_desktopkit.png
qtcreator_desktopkit

Click on the "Configure Project" button to get started.

Starting LibrePCB

Select the run configuration librepcb and click on the Run button:

qtcreator_run.png
qtcreator_run

Parallel Builds

If ninja is installed on your system, Qt Creator will use it by default, resulting in parallel builds (utilizing all your CPU cores) out of the box. If the fallback to GNU Make is being used, you may need to set make flags in order to achieve parallel builds.

Building on the Command Line

You can also build LibrePCB from the command line using cmake:

mkdir build && cd build
cmake ..
make -j8

Then run the librepcb binary in the build/apps/librepcb/ directory.

To install LibrePCB on your system, run make install.

Faster Rebuilds with ccache

If you regularly rebuild parts of LibrePCB, you can speed up that process by installing ccache and passing -DCMAKE_CXX_COMPILER_LAUNCHER=ccache to CMake.

cmake .. -DCMAKE_CXX_COMPILER_LAUNCHER=ccache

Changing the Install Prefix

By passing in the CMAKE_INSTALL_PREFIX parameter, you can change the install prefix. For example, if you want to install LibrePCB to /usr/local, use

cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local

Debug and Release Builds

By default CMake will create a release build without debug symbols.

To customize the build type, pass the CMAKE_BUILD_TYPE parameter to CMake. For example, to create a debug build:

cmake .. -DCMAKE_BUILD_TYPE=Debug

Available build types:

  • Debug: Debug build
  • Release: Standard release build
  • RelWithDebInfo: Release build with debug symbols
  • MinSizeRel: Release build optimized for minimal size

Compiler Warnings

By default, our own libraries and applications are compiled with -Wall. If you want to treat warnings as errors (advisable in CI, or before committing), pass the BUILD_DISALLOW_WARNINGS parameter to CMake:

cmake .. -DBUILD_DISALLOW_WARNINGS=1

Shared Resources Path

The share directory contains icons, fonts, templates and more resources that LibrePCB needs at runtime. On a Linux system, it is usually located at /usr/share/librepcb.

By default (unless LIBREPCB_REPRODUCIBLE is set), the build process will embed the absolute path to the share directory located within the source tree into the binary. When starting LibrePCB, it will first check whether the binary is running from within CMAKE_BINARY_DIR. If that is the case, the share directory in the source tree will be used. Otherwise, LibrePCB will fall back to ../share/librepcb relative to the application binary.

This will work out-of-the-box in many cases. However, when packaging LibrePCB, you should explicitly set the share directory path (either an absolute or a relative path).

cmake .. -DLIBREPCB_SHARE=/usr/share/librepcb

Reproducible Builds

So far, LibrePCB does not officially support reproducible builds. However, we allow turning off some features that make the binary non-reproducible (like embedded source directory paths, or embedded git commit hashes). This should make it easier to achieve reproducible builds in the future.

cmake .. -DLIBREPCB_REPRODUCIBLE=1

Dynamic Linking / Unbundling

By default, all dependencies (except for Qt) will be linked statically using vendored git submodules. If you prefer to unbundle some libraries, set the UNBUNDLE_xxx variable:

cmake .. -DUNBUNDLE_FONTOBENE_QT5=1 -DUNBUNDLE_POLYCLIPPING=1

To unbundle all dependencies that support it, use -DUNBUNDLE_ALL=1.

Right now, the following libraries can be unbundled:

Library Parameter Search Methods
dxflib UNBUNDLE_DXFLIB pkg-config
fontobene-qt5 UNBUNDLE_FONTOBENE_QT5 pkg-config, find_path
googletest UNBUNDLE_GTEST cmake, pkg-config
hoedown ¹ UNBUNDLE_HOEDOWN pkg-config
muparser UNBUNDLE_MUPARSER cmake, pkg-config
polyclipping UNBUNDLE_POLYCLIPPING pkg-config
quazip ² UNBUNDLE_QUAZIP cmake

¹ Note: Hoedown is only needed on Qt <5.14.
² Due to packaging issues with QuaZip 0.x, we only support QuaZip 1.x when unbundling. Using QuaZip 0.9 should work as well, but then you'll have to patch the cmake/FindQuaZip.cmake find script as well as potentially the include paths (quazip -> quazip5) yourself.