|
Congratulations on the ClamAV® version 1.0.0 LTS stable release!
On May 8, 2002, the first version 0.10 of the open source antivirus engine ClamAV was released. Memorandum: How to build ClamAV® using the CMake Build System on macOS
How to build ClamAV® using the CMake Build System on macOS
Autotools build system has been dropped. I'm running the latest feature release ClamAV 1.5.2 on macOS 26.5 Tahoe now. ClamAV 1.5.2 is available on ClamAVNet Download page! The release notes are here. This memorandum describes how to build ClamAV using the CMake build system and includes the following: 0) Important notes for building ClamAV 1.3.x on macOS Sonoma 14.x. 1) Install CMake Build System 2) Install Rust toolchain 3) Install pkg-config 4) Install Libcheck/Check 5) Install PCRE2 Libraries 6) Install OpenSSL Libraries 7) Install JSON-C Libraries 8) Install Ninja Build System 9) Build ClamAV with CMake Build System 10) Build ClamAV with Ninja Build System 11) Links… For instructions on how to build ClamAV, please refer to "How to Create a Folder Monitoring Program Using clamdscan on macOS". Regarding the Autotools build system, see "How to install ClamAV® from the Git sources on macOS". 0) Important notes for building ClamAV 1.3.x on macOS Sonoma 14.x. 1. Building ClamAV 1.3.x on macOS Sonoma 14.x may result in the following fatal error: clamd dyld[27427]: Library not loaded: @rpath/libjson-c.5.dylib Referenced from: <55D558AB-C718-3171-B72A-CBD668755360> /usr/local/clamXav/sbin/clamd Reason: tried: '/usr/local/clamXav/lib/libjson-c.5.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/clamXav/lib/libjson-c.5.dylib' (no such file), '/usr/local/clamXav/lib/libjson-c.5.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/clamXav/lib/libjson-c.5.dylib' (no such file) Abort trap: 6 freshclam dyld[27450]: Library not loaded: @rpath/libjson-c.5.dylib Referenced by: /usr/local/clamXav/bin/freshclam Reason: Attempted to use: '/usr/local/clamXav/lib/libjson-c.5.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/clamXav/lib/libjson-c.5.dylib' (no such file), '/usr/local/clamXav/lib/libjson-c.5.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/clamXav/lib/libjson-c.5.dylib' (no such file), (security policy does not allow @ path expansion) Abort trap: 6 2. To solve this problem, make symlinks to '/usr/local/clamXav/lib' as follows: sudo ln -s /usr/local/json-c/lib/libjson-c.dylib /usr/local/clamXav/lib/libjson-c.5.dylib 3. That's it. You can use clamAV again. 1) Install CMake CMake is an open-source, cross-platform family of tools designed to build, test and package software. 1. Download the latest CMake You can get CMake binary distribution for macOS. Download CMake.app and place it in the Applications directory. cd ~ curl -LO https://github.com/Kitware/CMake/releases/download/v4.3.2/cmake-4.3.2-macos-universal.tar.gz tar xzf cmake-4.3.2-macos-universal.tar.gz cp -R ~/cmake-4.3.2-macos-universal/CMake.app /Applications 2. For Command Line Use (to install symlinks to '/usr/local/bin') sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install 3. You can confirm the installation: which cmake /usr/local/bin/cmake cmake --version cmake version 4.3.2 Without using CMake.app you can build binary by yourself. 1. Download the latest CMake cd ~ curl -LO https://github.com/Kitware/CMake/releases/download/v4.3.2/cmake-4.3.2.tar.gz tar xzf cmake-4.3.2.tar.gz 2. Bootstrap CMake cd cmake-4.3.2 ./bootstrap --prefix=/usr/local/cmake 3. Compile and install CMake make && sudo make install 4. Set search path export PATH="/usr/local/cmake/bin:$PATH" 2) Install Rust toolchain 1. Download rustup and Install Rust toolchain curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh 2. Set search path export PATH="$HOME/.cargo/bin:$PATH" 3. You can confirm the installation: rustup --version rustup 1.29.0 (28d1352db 2026-03-05) info: This is the version for the rustup toolchain manager, not the rustc compiler. info: the currently active `rustc` version is `rustc 1.95.0 (59807616e 2026-04-14)` rustc --version rustc 1.95.0 (59807616e 2026-04-14) cargo --version cargo 1.95.0 (f2d3ce0bd 2026-03-21) 4. You can maintain the toolchain by periodically executing:
rustup update stable
info: syncing channel updates for stable-aarch64-apple-darwin
info: latest update on 2026-04-16 for version 1.95.0 (59807616e 2026-04-14)
info: removing previous version of component cargo
info: removing previous version of component clippy
info: removing previous version of component rust-docs
info: removing previous version of component rust-std
info: removing previous version of component rustc
info: removing previous version of component rustfmt
info: downloading 6 components
cargo installed 8.33 MiB
clippy installed 2.81 MiB
rust-docs installed 21.27 MiB
rust-std installed 26.05 MiB
rustc installed 64.52 MiB
rustfmt installed 1.44 MiB
stable-aarch64-apple-darwin updated - rustc 1.95.0 (59807616e 2026-04-14) (from rustc 1.94.1 (e408947bf 2026-03-25))
info: checking for self-update (current version: 1.29.0)
3) Install pkg-config 1. Download the latest pkg-config cd ~ curl -LO https://pkg-config.freedesktop.org/releases/pkg-config-0.29.2.tar.gz tar zxf pkg-config-0.29.2.tar.gz 2. Configure pkg-config cd pkg-config-0.29.2 export CFLAGS="-Wno-int-conversion" ./configure --with-internal-glib --prefix=/usr/local/pkgconfig --host=aarch64-apple-darwin 3. Compile and install pkg-config make && make check sudo make install 4. Set search path export PATH="/usr/local/keyconfig/bin:$PATH" 4) Install Libcheck/Check 1. Download the latest Check cd ~ curl -LO https://github.com/libcheck/check/releases/download/0.15.2/check-0.15.2.tar.gz tar zxf check-0.15.2.tar.gz 2. Configure Check cd check-0.15.2 ./configure --prefix=/usr/local/check 3. Compile and install Check make && make check sudo make install export PATH="/usr/local/check/bin:$PATH" 5) Install PCRE2 Libraries 1. Download the latest PCRE2 cd ~ curl -LO https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.47/pcre2-10.47.tar.bz2 tar zxf pcre2-10.47.tar.bz2 2. Configure PCRE2 cd pcre2-10.47 ./configure --prefix=/usr/local/pcre2 3. Compile and install PCRE2 make && make check sudo make install 6) Install OpenSSL Libraries 1. Download the latest OpenSSL The latest OpenSSL is version 4.0.0, but ClamAV 1.5.2 is currently incompatible with OpenSSL 4.0.x. When using OpenSSL 4.0.0, the following build errors occur: This crate is only compatible with OpenSSL (version 1.0.1 through 1.1.1, or 3), or LibreSSL 2.5 through 4.1.x, but a different version of OpenSSL was found. The build is now aborting due to this version mismatch. Thus download OpenSSL 3.6.2... cd ~ curl -LO https://github.com/openssl/openssl/releases/download/openssl-3.6.2/openssl-3.6.2.tar.gz tar zxf openssl-3.6.2.tar.gz 2. Configure OpenSSL cd openssl-3.6.2 ./configure --prefix=/usr/local/openssl 3. Compile and install OpenSSL make && make test sudo make install 4. Set search path export PATH="/usr/local/openssl/bin:$PATH" 5. You can confirm the installation: which openssl /usr/local/openssl/bin/openssl openssl version OpenSSL 3.6.2 7 Apr 2026 (Library: OpenSSL 3.6.2 7 Apr 2026) 7) Install JSON-C Libraries JSON-C is a JSON implementation in C. 1. Download JSON-C cd ~ curl -LO https://s3.amazonaws.com/json-c_releases/releases/json-c-0.18.tar.gz tar xzf json-c-0.18.tar.gz 2. Configure and Generate JSON-C cd json-c-0.18 mkdir build cd build cmake -D CMAKE_INSTALL_PREFIX=/usr/local/json-c .. 3. Compile and install JSON-C make && make test sudo make install 4. Create Symbolic Link sudo ln -s /usr/local/json-c/lib/libjson-c.dylib /usr/local/lib/ 8) Install Ninja Build System (Optional) Ninja is a small build system with a focus on speed. So this is an optional install. 1. Download Ninja cd ~ curl -LO https://github.com/ninja-build/ninja/archive/v1.13.2.tar.gz tar xzf v1.13.2.tar.gz 2. Configure and Generate Ninja cd ninja-1.13.2 mkdir build cd build cmake -D CMAKE_INSTALL_PREFIX=/usr/local/ninja/ .. 3. Compile and install Ninja make && make test sudo make install 4. Create Symbolic Link sudo ln -s /usr/local/ninja/bin/ninja /usr/local/bin/ 5. You can confirm the installation: which ninja /usr/local/bin/ninja ninja --version 1.13.2 9) Build ClamAV with CMake Build System 1. Download the latest feature release ClamAV 1.5.2 from ClamAVNet. cd ~ curl -LO https://www.clamav.net/downloads/production/clamav-1.5.2.tar.gz tar zxf clamav-1.5.2.tar.gz 2. Set CMake options and library paths and Configure and Generate. cd clamav-1.5.2 mkdir build cd build cmake \ -D CMAKE_BUILD_TYPE=Release \ -D CMAKE_INSTALL_PREFIX=/usr/local/clamXav/ \ -D BYTECODE_RUNTIME="interpreter" \ -D OPTIMIZE=ON \ -D ENABLE_JSON_SHARED=OFF \ -D ENABLE_TESTS=ON \ -D LIBCHECK_ROOT_DIR=/usr/local/check \ -D LIBCHECK_INCLUDE_DIR=/usr/local/check/include/ \ -D LIBCHECK_LIBRARY=/usr/local/check/lib/libcheck.dylib \ -D OPENSSL_ROOT_DIR=/usr/local/openssl/ \ -D OPENSSL_CRYPTO_LIBRARY=/usr/local/openssl/lib/libcrypto.dylib \ -D OPENSSL_SSL_LIBRARY=/usr/local/openssl/lib/libssl.dylib \ -D PCRE2_INCLUDE_DIR=/usr/local/pcre2/include/ \ -D PCRE2_LIBRARY=/usr/local/pcre2/lib/libpcre2-8.0.dylib \ -D JSONC_INCLUDE_DIR=/usr/local/json-c/include/json-c/ \ -D JSONC_LIBRARY=/usr/local/json-c/lib/libjson-c.dylib \ .. 3. You get results as below: -- Configuring done (32.9s) -- Generating done (0.8s) -- Build files have been written to: /Users/xxx/Desktop/clamav-1.5.2/build 4. Compile and make test; make && make test 5. You get results as below:
Running tests...
Test project /Users/xxx/Desktop/clamav-1.5.2/build
Connected to MAKE jobserver
Start 1: libclamav
1/6 Test #1: libclamav ........................ Passed 5.31 sec
Start 2: libclamav_rust
2/6 Test #2: libclamav_rust ................... Passed 6.76 sec
Start 3: clamscan
3/6 Test #3: clamscan ......................... Passed 0.04 sec
Start 4: clamd
4/6 Test #4: clamd ............................ Passed 9.90 sec
Start 5: freshclam
5/6 Test #5: freshclam ........................ Passed 40.95 sec
Start 6: sigtool
6/6 Test #6: sigtool .......................... Passed 0.39 sec
100% tests passed, 0 tests failed out of 6
6. Install ClamAV® sudo make all install 10) Build ClamAV with Ninja Build System 1. Download the latest feature release ClamAV 1.5.2 from ClamAVNet. cd ~ curl -LO https://www.clamav.net/downloads/production/clamav-1.5.2.tar.gz 2. Set the build generator to Ninja, set Options and Library Paths, Configure and Generate cd clamav-1.5.2 mkdir build cd build cmake -G Ninja \ -D CMAKE_BUILD_TYPE=Release \ -D CMAKE_INSTALL_PREFIX=/usr/local/clamXav/ \ -D ENABLE_JSON_SHARED=OFF \ -D BYTECODE_RUNTIME="interpreter" \ -D ENABLE_TESTS=ON \ -D LIBCHECK_ROOT_DIR=/usr/local/check \ -D LIBCHECK_INCLUDE_DIR=/usr/local/check/include/ \ -D LIBCHECK_LIBRARY=/usr/local/check/lib/libcheck.dylib \ -D OPENSSL_ROOT_DIR=/usr/local/openssl/ \ -D OPENSSL_CRYPTO_LIBRARY=/usr/local/openssl/lib/libcrypto.dylib \ -D OPENSSL_SSL_LIBRARY=/usr/local/openssl/lib/libssl.dylib \ -D PCRE2_INCLUDE_DIR=/usr/local/pcre2/include/ \ -D PCRE2_LIBRARY=/usr/local/pcre2/lib/libpcre2-8.0.dylib \ -D JSONC_INCLUDE_DIR=/usr/local/json-c/include/json-c/ \ -D JSONC_LIBRARY=/usr/local/json-c/lib/libjson-c.dylib \ .. 3. You get results as below: -- Configuring done -- Generating done -- Build files have been written to: /Users/xxx/clamav-1.5.2/build 4. Compile and make test ninja && ninja test 5. You get results as below:
Running tests...
Test project /Users/xxx/Desktop/clamav-1.5.2/build
Start 1: libclamav
1/6 Test #1: libclamav ........................ Passed 5.30 sec
Start 2: libclamav_rust
2/6 Test #2: libclamav_rust ................... Passed 6.24 sec
Start 3: clamscan
3/6 Test #3: clamscan ......................... Passed 0.04 sec
Start 4: clamd
4/6 Test #4: clamd ............................ Passed 9.90 sec
Start 5: freshclam
5/6 Test #5: freshclam ........................ Passed 40.94 sec
Start 6: sigtool
6/6 Test #6: sigtool .......................... Passed 0.39 sec
100% tests passed, 0 tests failed out of 6
6. Install ClamAV® sudo ninja install
|