Building on POSIX

To build NZBGet you will need:

If you face issues with Boost.JSON on your system, you can skip it - CMake will take care of it.

  • And the following libraries are optional:

Please note that you also need the developer packages for these libraries too, they package names have often suffix “dev” or “devel”. On other systems you may need to download the libraries at the given URLs and compile them (see hints below).

Debian:

apt install cmake build-essential libncurses-dev libssl-dev libxml2-dev zlib1g-dev
  • Debian 12 (bookworm)
apt install libboost-json1.81-dev
apt install libboost-test1.81-dev #(optional: for testing)
  • Debian 13 (trixie)
apt install libboost-json-dev 
apt install libboost-test-dev #(optional: for testing)
  • For static code analysis:
apt install clang-tidy

FreeBSD:

pkg install cmake ncurses openssl libxml2 zlib boost-libs

macOS:

xcode-select --install
brew install cmake ncurses openssl libxml2 zlib boost

4. Installation on POSIX

Installation from the source distribution archive (nzbget-VERSION.tar.gz):

  • Untar the nzbget-source:
tar -zxf nzbget-VERSION.tar.gz
  • Change into nzbget-directory:
cd nzbget-VERSION
  • Configure:
mkdir build
cd build
cmake ..
  • In a case you don’t have root access or want to install the program in your home directory use the configure parameter -DCMAKE_INSTALL_PREFIX:
cmake .. -DCMAKE_INSTALL_PREFIX=~/usr
  • Build, specifying (-j 8) how many CPU cores to use to speed up compilation:
cmake --build . -j 8 
  • Install:
cmake --install .
  • Uninstall:
cmake --build . --target uninstall
  • Install configuration files into /etc via:
cmake --build . --target install-conf
  • Uninstall configuration files into /etc via:
cmake --build . --target uninstall-conf
  • Run tests on POSIX:
ctest

Configure-options


You may run configure with additional arguments:

  • Enable tests:
cmake .. -DENABLE_TESTS=ON
  • Enable Clang-Tidy static code analizer:
cmake .. -DENABLE_CLANG_TIDY=ON
  • Disable ncurses. Use this option if you can not use ncurses.
cmake .. -DDISABLE_CURSES=ON
  • Disable parcheck. Use this option if you have troubles when compiling par2-module.
cmake .. -DDISABLE_PARCHECK=ON
  • Disable TLS. Use this option if you can not neither OpenSSL.
cmake .. -DDISABLE_TLS=ON
  • Disable gzip. Use this option if you can not use zlib.
cmake .. -DDISABLE_GZIP=ON
  • Disable sigchld-handler. The disabling may be neccessary on 32-Bit BSD.
cmake .. -DDISABLE_SIGCHLD_HANDLER=ON
  • For debug build.
cmake .. -DCMAKE_BUILD_TYPE=Debug
  - Enable leak, undefined, address sanitizers

cmake .. -DENABLE_SANITIZERS=ON

  - To get a static binary, 
```bash
cmake .. -DENABLE_STATIC=ON

LIBS and INCLUDES env variables can be useful for static linking, since CMake looks for shared libraries by default

export LIBS="-lncurses -ltinfo -lboost_json -lxml2 -lz -lm -lssl -lcrypto -Wl,--whole-archive -lpthread -Wl,--no-whole-archive"
export INCLUDES="/usr/include/;/usr/include/libxml2/"
cmake .. -DENABLE_STATIC=ON

Cppcheck

  • Install Cppcheck
apt install cppcheck
  • Generate a compile database:
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .
  • The file compile_commands.json is created in the current folder. Now run Cppcheck like this:
cppcheck --project=compile_commands.json
  • To ignore certain folders you can use -i. This will skip analysis of source files in the foo folder.
cppcheck --project=compile_commands.json -ifoo
/js/scripts.min.js