SW Genlock supports two build systems:
- Meson (recommended for speed and simplicity)
- CMake (cross-platform, Visual Studio support)
Meson provides the fastest build times with clean syntax and excellent cross-platform support.
- Git clone this repository
- Install dependencies:
sudo apt install libdrm-dev libpciaccess-dev meson ninja-build- If the directory /usr/include/drm does not exist, run:
sudo apt install -y linux-libc-dev
- Build using the provided script:
./build_meson.sh # Default: Release build
./build_meson.sh debug # For debug build
./build_meson.sh release clean # Clean buildOr manually:
meson setup builddir
meson compile -C builddirBuild outputs will be in:
builddir/lib/- libvsyncalter.so and libvsyncalter.abuilddir/pllctl/- pllctl executablebuilddir/vblmon/- vblmon executablebuilddir/swgenlock/- swgenlock executable
For detailed Meson documentation, see MESON_BUILD.md.
CMake provides cross-platform support, automatic platform detection, and Visual Studio integration for Windows development.
- Git clone this repository
- Install dependencies:
sudo apt install libdrm-dev libpciaccess-dev cmake- If the directory /usr/include/drm does not exist, run:
sudo apt install -y linux-libc-dev
- Build using the provided script:
./build_cmake.sh # Default: Release build
./build_cmake.sh Debug # For debug buildOr manually:
mkdir build && cd build
cmake ..
make -j$(nproc)Build outputs will be in:
build/lib/- libvsyncalter.so and libvsyncalter.abuild/pllctl/- pllctl executablebuild/vblmon/- vblmon executablebuild/swgenlock/- swgenlock executable
CMake options (configure with -D flags):
BUILD_SHARED_LIBS=ON/OFF- Build shared library (default: ON)BUILD_SWGENLOCK=ON/OFF- Build swgenlock applications (default: ON)BUILD_PLLCTL=ON/OFF- Build pllctl (default: ON)BUILD_VBLMON=ON/OFF- Build vblmon (default: ON)
Example: cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug ..
The Vsync library is distributed in both dynamic (.so) and static (.a) binary formats, allowing users to choose between dynamic and static linking depending on their application requirements. This library includes essential functions such as retrieving vblank timestamps and adjusting the vblank timestamp drift by specified microseconds. Additionally, all operations related to Phase-Locked Loop (PLL) programming are encapsulated within the library, providing a comprehensive suite of tools for managing display synchronization.
When linking against the static library (libvsyncalter.a), the final binary must be linked using g++ rather than gcc. This is because the static library contains C++ object code but does not include the C++ standard library symbols (e.g., operator new, std::mutex, virtual tables).
$ g++ -o app main.c libvsyncalter.a -lpciaccess -ldrm -lrt -lmLinking with gcc in this case will typically result in undefined reference errors to C++ runtime symbols.
When using the shared library version (libvsyncalter.so), the final binary can be linked using either gcc or g++. All necessary C++ symbols are already resolved and included in the shared object.
The system dynamic linker will load the required C++ runtime (libstdc++) at runtime.
$ gcc -o app main.c -L. -lvsyncalter -lpciaccess -ldrm -lrt -lmThis allows the shared library to be used safely from C code, since the C++ functions in vsync lib are exposed with C-compatible linkage (i.e., using extern "C" in headers). The reference applications are linked using g++, while the unit tests are compiled with gcc to ensure compatibility with the pure C interface.
The library supports code coverage instrumentation for unit testing purposes. Code coverage is disabled by default in normal builds but can be enabled when running unit tests.
CMake: Use -DUNITTEST_ENABLE_COVERAGE=ON to enable code coverage
Meson: Use -Denable_coverage=true to enable code coverage
The unit test build scripts (unittest/build_cmake.sh and unittest/build_meson.sh) automatically enable code coverage.
Note: The build scripts automatically handle build configuration to ensure:
- When building for unit tests: code coverage is enabled
- When building normally from the root: code coverage is disabled
If a build directory already exists with the opposite configuration, the scripts will automatically reconfigure it. Alternatively, you can manually delete the build directory to start fresh:
rm -rf build # For CMake
rm -rf builddir # For MesonFor detailed unit testing and code coverage instructions, see unittest/unittest.md.