Apache Log4cxx Version 1.0.0
|
Building and testing Log4cxx on a Unix platform with packaged APR and APR-Util.
Make sure cmake 3.13+, g++ and make are available, install or build apr 1.x, apr-util 1.x, gzip and zip.
Linux example:
Windows Example: Building and testing Log4cxx on a Microsoft Windows with APR, Expat and APR-Util built from source extracted into apr-1.7.0, libexpat(from github) and apr-util-1.6.1 in HOMEPATH%/Libraries.
Option | Usage |
---|---|
-DLOG4CXX_WCHAR_T=no | Enable wchar_t API methods, choice of yes (default), no. |
-DLOG4CXX_UNICHAR=yes | Enable UniChar API methods, choice of yes, no (default). |
-DLOG4CXX_CFSTRING=yes | Enable CFString API methods, requires Mac OS/X CoreFoundation, choice of yes, no (default). |
-DBUILD_TESTING=off | Do not build tests. Tests are built by default |
-DBUILD_SHARED_LIBS=off | Build Log4cxx as a static library. A dynamically linked Log4cxx library is built by default. Any compilation unit that includes a Log4cxx header must define LOG4CXX_STATIC. |
-DAPU_STATIC=yes | Link to the APR-Util static library. By default, the Log4cxx shared library is linked to the APR-Util shared library. If BUILD_SHARED_LIBS=off, the static APR-Util library is used. |
-DAPR_STATIC=yes | Link to the APR static library. By default, the Log4cxx shared library is linked to the APR shared library. If BUILD_SHARED_LIBS=off, the static APR library is always used. |
-DLOG4CXX_TEST_PROGRAM_PATH=path | An extra path to prepend to the PATH for test programs. Log4cxx requires zip, sed, and grep on the PATH in order for the tests to work properly. |
-DPREFER_BOOST=on | Prefer the Boost version of dependent libraries over standard library |
By default, Log4cxx attempts to use at least C++17 to compile. This is to avoid 3rd party dependencies as much as possible. If C++17 is not available, a search for Boost will be taken and those libaries will be used instead. If you would prefer to use Boost, there are two options you have:
-DPREFER_BOOST=ON
to CMake when compiling. This will ignore the results of the tests that check for the standard version of components that are required. Note that this will switch all components, regardless of the C++ version in effect at compile time.-DCMAKE_CXX_STANDARD=11
for example. This will still to check for standard versions of required components, but it will fall back to using Boost for newer components added in C++17.APR and APR-Util are provided by the platform in Mac OS/X 10.5 and iODBC in 10.4.
cmake can be installed by typing "brew install cmake".
APR, APR-Util, openssl, gzip and zip may be installed by:
CMake can be built from source by typing:
APR, APR-Util, gzip and zip may be installed from the ports collection by:
The easiest way to get dependencies installed is to use vcpkg(for APR/expat), and msys2 for the command-line utilities(zip, grep, sed).
Msys2 can be downloaded from: https://www.msys2.org/ By default, this will be installed under C:\msys2, so you can add that to the build PATH by setting LOG4CXX_TEST_PROGRAM_PATH=C:/msys64/usr/bin in your build settings.
For vcpkg, follow the directions at https://github.com/microsoft/vcpkg#quick-start-windows and then install the dependencies needed using vcpkg install apr apr-util
.
A log4cxxConfig.cmake and log4cxxConfigVersion.cmake is installed to allow use of find_package() in your CMakeLists.txt.
Below are example cmake commands that compile and link "myApplication" with Log4cxx.