Congratulations on the ClamAV® version 1.0.0 LTS stable release!

Congratulations on the ClamAV® version 1.0.0 LTS stable release!

ClamAV reaches 1.0.0

On May 8, 2002, the first version 0.10 of the open source antivirus engine ClamAV was released.
On November 28, 2022, ClamAV finally reached version 1.0.0 LTS stable release…

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.
CMake is now the required build system in the ClamAV 0.104.x.
Instead of Autotools (eg: ./configure && make && sudo make install), CMake is required to build ClamAV.
Besides CMake, you need some libclamav dependencies (libpcre2 for RegEx, openssl for Crypto, json-c for JSON) to build ClamAV. And it may also be necessary to install other libraries such as pkg-config.
For further information, see " ClamAV 0.104.0 released" and "Installation Instructions".

Starting with ClamAV 0.105.x, Rust toolchain is required to compile portions of libclamav.
See "Install Rust toolchain".



I'm running the latest feature release ClamAV 1.3.0 on macOS 14.3 Sonoma now.
ClamAV 1.3.0 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.2.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.2.x on macOS Sonoma 14.x.

1. Building ClamAV 1.2.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.5.dylib /usr/local/clamXav/lib/

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/v3.28.3/cmake-3.28.3-macos-universal.tar.gz
tar xzf cmake-3.28.3-macos-universal.tar.gz
cp -r ~/cmake-3.28.3-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 3.28.3




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/v3.28.3/cmake-3.28.3.tar.gz
tar xzf cmake-3.28.3.tar.gz

2. Bootstrap CMake
cd cmake-3.28.3
./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.26.0 (5af9b9484 2023-04-05)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.76.0 (07dca489a 2024-02-04)`

rustc --version
rustc 1.76.0 (07dca489a 2024-02-04)

cargo --version
cargo 1.76.0 (c84b36747 2024-01-18)

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 2024-02-08, rust version 1.76.0 (07dca489a 2024-02-04)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
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'
 14.7 MiB /  14.7 MiB (100 %)   5.2 MiB/s in  2s ETA:  0s
info: installing component 'rust-std'
 25.3 MiB /  25.3 MiB (100 %)  13.4 MiB/s in  2s ETA:  0s
info: installing component 'rustc'
 55.1 MiB /  55.1 MiB (100 %)  14.1 MiB/s in  4s ETA:  0s
info: installing component 'rustfmt'

  stable-x86_64-apple-darwin updated - rustc 1.76.0 (07dca489a 2024-02-04) (from rustc 1.75.0 (82e1608df 2023-12-21))

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
4. Set search path
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.43/pcre2-10.43.tar.bz2
tar zxf pcre2-10.43.tar.bz2

2. Configure PCRE2
cd pcre2-10.43
./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-3.8.2.tar.gz
tar zxf libressl-3.8.2.tar.gz

2. Configure LibreSSL
cd libressl-3.8.2
./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 3.8.2





6-2. When you use OpenSSL…

1. Download the latest OpenSSL
cd ~
curl -LO https://www.openssl.org/source/openssl-3.2.1.tar.gz
tar zxf openssl-3.2.1.tar.gz

2. Configure OpenSSL
cd openssl-3.2.1
./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.2.1 30 Jan 2024 (Library: OpenSSL 3.2.1 30 Jan 2024)




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.17.tar.gz
tar xzf json-c-0.17.tar.gz

2. Configure and Generate JSON-C
cd json-c-0.17
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.5.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.11.1.tar.gz
tar xzf v1.11.1.tar.gz

2. Configure and Generate Ninja
cd ninja-1.11.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.11.1




9) Build ClamAV with CMake Build System

9-1. When you use LibreSSL…

1. Download the latest feature release ClamAV 1.3.0 from ClamAVNet.
cd ~
curl -LO https://www.clamav.net/downloads/production/clamav-1.3.0.tar.gz
tar zxf clamav-1.3.0.tar.gz

2. Set CMake options and library paths and Configure and Generate.
cd clamav-1.3.0
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.0.dylib \
-D OPENSSL_ROOT_DIR=/usr/local/libressl/ \
-D OPENSSL_CRYPTO_LIBRARY=/usr/local/libressl/lib/libcrypto.52.dylib \
-D OPENSSL_SSL_LIBRARY=/usr/local/libressl/lib/libssl.55.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.5.dylib \
..

3. You get results as below:
-- Configuring done (30.1s)
-- Generating done (0.6s)
-- Build files have been written to: /Users/xxx/Desktop/clamav-1.3.0/build

4. Compile and make test;
make && make test

5. You get results as below:
Running tests...
Test project /Users/xxx/Desktop/clamav-1.3.0/build
    Start 1: libclamav
1/6 Test #1: libclamav ........................   Passed   13.90 sec
    Start 2: libclamav_rust
2/6 Test #2: libclamav_rust ...................   Passed    8.27 sec
    Start 3: clamscan
3/6 Test #3: clamscan .........................   Passed    0.12 sec
    Start 4: clamd
4/6 Test #4: clamd ............................   Passed   13.57 sec
    Start 5: freshclam
5/6 Test #5: freshclam ........................   Passed   41.35 sec
    Start 6: sigtool
6/6 Test #6: sigtool ..........................   Passed    0.49 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.3.0 from ClamAVNet.
cd ~
curl -LO https://www.clamav.net/downloads/production/clamav-1.3.0.tar.gz
tar zxf clamav-1.3.0.tar.gz

2. Set CMake options and library paths and Configure and Generate.
cd clamav-1.3.0
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.0.dylib \
-D OPENSSL_ROOT_DIR=/usr/local/openssl/ \
-D OPENSSL_CRYPTO_LIBRARY=/usr/local/openssl/lib/libcrypto.3.dylib \
-D OPENSSL_SSL_LIBRARY=/usr/local/openssl/lib/libssl.3.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.5.dylib \
..

3. You get results as below:
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/xxx/clamav-1.3.0

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.3.0 from ClamAVNet.
cd ~
curl -LO https://www.clamav.net/downloads/production/clamav-1.3.0.tar.gz

2. Set the build generator to Ninja, set Options and Library Paths, Configure and Generate
cd clamav-1.3.0
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.0.dylib \
-D OPENSSL_ROOT_DIR=/usr/local/libressl/ \
-D OPENSSL_CRYPTO_LIBRARY=/usr/local/libressl/lib/libcrypto.52.dylib \
-D OPENSSL_SSL_LIBRARY=/usr/local/libressl/lib/libssl.55.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.5.dylib \
..

3. You get results as below:
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/xxx/clamav-1.3.0/build

4. Compile and make test
ninja && ninja test

5. You get results as below:
Running tests...
Test project /Users/xxx/clamav-1.3.0/build
    Start 1: libclamav
1/6 Test #1: libclamav ........................   Passed   10.27 sec
    Start 2: libclamav_rust
2/6 Test #2: libclamav_rust ...................   Passed   69.69 sec
    Start 3: clamscan
3/6 Test #3: clamscan .........................   Passed    3.70 sec
    Start 4: clamd
4/6 Test #4: clamd ............................   Passed   11.37 sec
    Start 5: freshclam
5/6 Test #5: freshclam ........................   Passed   32.46 sec
    Start 6: sigtool
6/6 Test #6: sigtool ..........................   Passed    0.24 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.3.0 from ClamAVNet.
cd ~
curl -LO https://www.clamav.net/downloads/production/clamav-1.3.0.tar.gz

2. Set the build generator to Ninja, set Options and Library Paths, Configure and Generate
cd clamav-1.3.0
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.0.dylib \
-D OPENSSL_ROOT_DIR=/usr/local/openssl/ \
-D OPENSSL_CRYPTO_LIBRARY=/usr/local/openssl/lib/libcrypto.3.dylib \
-D OPENSSL_SSL_LIBRARY=/usr/local/openssl/lib/libssl.3.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.5.dylib \
..

3. You get results as below:
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/xxx/clamav-1.3.0/build

4. Compile and install ClamAV®
ninja && ninja test
sudo ninja install



Links…

mail