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 stable release ClamAV 1.4.2 on macOS 15.4.1 Sequoia now. ClamAV 1.4.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 6-1.When you use LibreSSL… 6-2.When you use OpenSSL… 7) Install JSON-C Libraries 8) Install Ninja Build System 9) Build ClamAV with CMake Build System 9-1.When you use LibreSSL… 9-2.When you use OpenSSL… 10) Build ClamAV with Ninja Build System 10-1.When you use LibreSSL… 10-2.When you use OpenSSL… 11) Links… 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.0.1/cmake-4.0.1-macos-universal.tar.gz tar xzf cmake-4.0.1-macos-universal.tar.gz cp -r ~/cmake-4.0.1-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.0.1 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.0.1/cmake-4.0.1.tar.gz tar xzf cmake-4.0.1.tar.gz 2. Bootstrap CMake cd cmake-4.0.1 ./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.28.1 (f9edccde0 2025-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.86.0 (05f9846f8 2025-03-31)` rustc --version rustc 1.86.0 (05f9846f8 2025-03-31) cargo --version cargo 1.86.0 (adf9b6ad1 2025-02-28) 4. You can maintain the toolchain by periodically executing: rustup update stable info: syncing channel updates for 'stable-x86_64-apple-darwin' info: latest update on 2025-04-03, rust version 1.86.0 (05f9846f8 2025-03-31) info: downloading component 'cargo' info: downloading component 'clippy' info: downloading component 'rust-docs' 21.3 MiB / 21.3 MiB (100 %) 10.2 MiB/s in 1s info: downloading component 'rust-std' info: downloading component 'rustc' info: downloading component 'rustfmt' 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: installing component 'cargo' info: installing component 'clippy' info: installing component 'rust-docs' 21.3 MiB / 21.3 MiB (100 %) 7.1 MiB/s in 3s info: installing component 'rust-std' 25.9 MiB / 25.9 MiB (100 %) 14.3 MiB/s in 1s info: installing component 'rustc' 65.1 MiB / 65.1 MiB (100 %) 15.5 MiB/s in 4s info: installing component 'rustfmt' stable-x86_64-apple-darwin updated - rustc 1.86.0 (05f9846f8 2025-03-31) (from rustc 1.85.1 (4eb161250 2025-03-15)) info: checking for self-update 3) Install pkg-config 1. Download the latest pkg-config cd ~ curl -O 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 LDFLAGS="-framework CoreFoundation" ./configure --with-internal-glib --prefix=/usr/local/pkgconfig 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.45/pcre2-10.45.tar.bz2 tar zxf pcre2-10.45.tar.bz2 2. Configure PCRE2 cd pcre2-10.45 ./configure --prefix=/usr/local/pcre2 3. Compile and install PCRE2 make && make check sudo make install 6) Install OpenSSL Libraries 6-1. When you use LibreSSL… 1. Download the latest LibreSSL cd ~ curl -LO https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-4.0.0.tar.gz tar zxf libressl-4.0.0.tar.gz 2. Configure LibreSSL cd libressl-4.0.0 ./configure --prefix=/usr/local/libressl 3. Compile and install LibreSSL make && make check sudo make install 4. Set search path export PATH="/usr/local/libressl/bin:$PATH" 5. You can confirm the installation: which openssl /usr/local/libressl/bin/openssl openssl version LibreSSL 4.0.0 6-2. When you use OpenSSL… 1. Download the latest OpenSSL cd ~ curl -LO https://github.com/openssl/openssl/releases/download/openssl-3.5.0/openssl-3.5.0.tar.gz tar zxf openssl-3.5.0.tar.gz 2. Configure OpenSSL cd openssl-3.5.0 ./configure darwin64-x86_64-cc --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.5.0 8 Apr 2025 (Library: OpenSSL 3.5.0 8 Apr 2025) 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.12.1.tar.gz tar xzf v1.12.1.tar.gz 2. Configure and Generate Ninja cd ninja-1.12.1 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.12.1 9) Build ClamAV with CMake Build System 9-1. When you use LibreSSL… 1. Download the latest feature release ClamAV 1.4.2 from ClamAVNet. cd ~ curl -LO https://www.clamav.net/downloads/production/clamav-1.4.2.tar.gz tar zxf clamav-1.4.2.tar.gz 2. Set CMake options and library paths and Configure and Generate. cd clamav-1.4.2 mkdir build cd build cmake \ -D CMAKE_BUILD_TYPE=Release \ -D OPTIMIZE=ON \ -D BYTECODE_RUNTIME="interpreter" \ -D CMAKE_INSTALL_PREFIX=/usr/local/clamXav/ \ -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/libressl/ \ -D OPENSSL_CRYPTO_LIBRARY=/usr/local/libressl/lib/libcrypto.dylib \ -D OPENSSL_SSL_LIBRARY=/usr/local/libressl/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.4.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.4.2/build Connected to MAKE jobserver Start 1: libclamav 1/6 Test #1: libclamav ........................ Passed 15.83 sec Start 2: libclamav_rust 2/6 Test #2: libclamav_rust ................... Passed 10.26 sec Start 3: clamscan 3/6 Test #3: clamscan ......................... Passed 0.12 sec Start 4: clamd 4/6 Test #4: clamd ............................ Passed 15.04 sec Start 5: freshclam 5/6 Test #5: freshclam ........................ Passed 41.48 sec Start 6: sigtool 6/6 Test #6: sigtool .......................... Passed 0.48 sec 100% tests passed, 0 tests failed out of 6 6. Install ClamAV® sudo make all install 9-2. When you use OpenSSL… 1. Download the latest feature release ClamAV 1.4.2 from ClamAVNet. cd ~ curl -LO https://www.clamav.net/downloads/production/clamav-1.4.2.tar.gz tar zxf clamav-1.4.2.tar.gz 2. Set CMake options and library paths and Configure and Generate. cd clamav-1.4.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 -- Generating done -- Build files have been written to: /Users/xxx/clamav-1.4.2 4. Compile and install ClamAV® make && make test sudo make all install 10) Build ClamAV with Ninja Build System 10-1. When you use LibreSSL… 1. Download the latest feature release ClamAV 1.4.2 from ClamAVNet. cd ~ curl -LO https://www.clamav.net/downloads/production/clamav-1.4.2.tar.gz 2. Set the build generator to Ninja, set Options and Library Paths, Configure and Generate cd clamav-1.4.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/libressl/ \ -D OPENSSL_CRYPTO_LIBRARY=/usr/local/libressl/lib/libcrypto.dylib \ -D OPENSSL_SSL_LIBRARY=/usr/local/libressl/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.4.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.4.2/build Start 1: libclamav 1/6 Test #1: libclamav ........................ Passed 15.28 sec Start 2: libclamav_rust 2/6 Test #2: libclamav_rust ................... Passed 7.49 sec Start 3: clamscan 3/6 Test #3: clamscan ......................... Passed 0.12 sec Start 4: clamd 4/6 Test #4: clamd ............................ Passed 14.84 sec Start 5: freshclam 5/6 Test #5: freshclam ........................ Passed 41.37 sec Start 6: sigtool 6/6 Test #6: sigtool .......................... Passed 0.47 sec 100% tests passed, 0 tests failed out of 6 6. Install ClamAV® sudo ninja install 10-2. When you use OpenSSL… 1. Download the latest feature release ClamAV 1.4.2 from ClamAVNet. cd ~ curl -LO https://www.clamav.net/downloads/production/clamav-1.4.2.tar.gz 2. Set the build generator to Ninja, set Options and Library Paths, Configure and Generate cd clamav-1.4.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.4.2/build 4. Compile and install ClamAV® ninja && ninja test sudo ninja install
|