chanibal / log4cxx-vs142

Helpers to use log4cxx on Visual Studio 2019 with 142 toolkit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Building log4cxx on Windows

This package offers files to help build log4cxx from the source files found on Apache's website, with Windows environment in mind, and more specifically Visual Studio.
It consists in of 3 separates elements:

  • a set of scripts to configure and patch the code,
  • a ready-to-use solution for Visual Studio 2015,
  • a CMake file that can be used to build with other version of Visual Studio or even other environments.

Installation

Prerequisite

For the scripts to work, you need to have sed installed and the sed.exe repository added to your PATH. If sed is not installed or if something is not working properly, you can make the required actions by hand (see explanations below).

Setup

  1. Clone or download this project. We will call <rootDir> the corresponding directory.

  2. Download the following sources:

  3. unzip them in <rootDir> and rename the folders apr, apr-util and log4cxx, respectively.
    Your working directory should be organized as follow:

     <rootDir>
        |-- <apr>
        |-- <apr-util>
        |-- <cmake>
        |-- <log4cxx>
        |-- <msvc15>
        |-- <patch>
        |-- readme.md
    
  4. In <patch>, execute configure.bat

You can now use either the Visual Studio 2015 solution in <msvc15> or CMake with the CMakeLists.txt in <cmake>

Configuration and patch (and how to do without sed)

We explain the work done by the scripts and give a step by step details.
There are two aspects to the scripts:

  • copying a bunch of headers or replacing values in them, to configure the code for (modern) Windows systems,
  • patching the log4cxx code to work with with recent Visual Studio version. In particular, C++11 capable compilers are not happy with some default constructors and destructors.

Here are the steps performed by patch/configure.bat:

  1. go to rootDir/log4cxx

  2. execute configure.bat

  3. execute configure-aprutil.bat

    1. in rootDir/apr-util/include/apu.hw, look for the line #define APU_HAVE_APR_ICONV and set the value to 0
    2. in rootDir/apr-util/include/apr_ldap.hw, look for the line #define APR_HAS_LDAP and set the value to 0
  4. apply rootDir/buildVS/patch.bat

    1. in rootDir/log4cxx/src/main/cpp/stringhelper.cpp, add #include<iterator> in the include section
    2. in rootDir/log4cxx/src/main/include/log4cxx/helpers/objectimpl.h, add the following macros after the include section:
    #define DELETED_CTORS(T) \
        T(const T&) = delete;\
        T& operator=(const T&) = delete;
    
    #define DEFAULTED_AND_DELETED_CTORS(T) \
       T() = default;\
       T(const T&) = delete;\
       T& operator=(const T&) = delete;
    
    1. in rootDir/log4cxx/src/main/include/log4cxx/pattern/patternconverter.h, add DEFAULTED_AND_DELETED_CTORS(PatternConverter) after END_LOG4CXX_CAST_MAP()
    2. in rootDir/log4cxx/src/main/include/log4cxx/rolling/RollingPolicyBase.h, add DELETED_CTORS(RollingPolicyBase) above virtual ~RollingPolicyBase();
    3. in rootDir/log4cxx/src/main/include/log4cxx/rolling/TriggeringPolicy.h, add DEFAULTED_AND_DELETED_CTORS(TriggeringPolicy) above virtual ~TriggeringPolicy();
    4. in rootDir/log4cxx/src/main/include/log4cxx/spi/Filter.h, add DELETED_CTORS(Filter) after Filter();
    5. in rootDir/log4cxx/src/main/include/log4cxx/Layout.h, add DEFAULTED_AND_DELETED_CTORS(Layout) above virtual ~Layout();
    6. in rootDir/log4cxx/src/main/include/log4cxx/log4cxx.h, add && _MSC_VER < 1600 to the two tests #if defined(_MSC_VER) && !defined(LOG4CXX_STATIC) && defined(LOG4CXX) and #elif defined(_MSC_VER) && !defined(LOG4CXX_STATIC)
  5. (optional) remove the temporary files possibly generated by sed (name such as sedAbCDef) in rootDir/log4cxx and rootDir/buildVS.

Notes

Visual Studio solution

The solution automatically converted from the .dsw found in the log4cxx source package was not usable. The solution proposed here is a clean one built from scratch, using the automatically converted one as a guide.
log4cxx.dll will be located in buildVS/bin/plateform/configuration while apr.lib, xml.lib and apr-util.lib will be found in buildVS/lib/plateform/configuration

CMake file

The CMakeLists.txt file was initially built to generate a Visual Studio solution very close to the one mentionned above. The idea is to have a cmake base that can be reused for different compilers/systems.
Because of its history (.dsw -> .sln -> cmake and configure.bat), it is certainly not the optimal way to use CMake for this project. In particular:

  • at least part of the configuration/patch steps could be done in CMake,
  • we are not using the existing CMakeLists for apr and apr-util (which are more complete, but also more complex, with options not available through the original configure+.dsw).
Tested versions

The content of this project was tested on Windows 7 with

  • apr 1.5.2
  • apr-util 1.5.4
  • log4cxx 0.10.0
  • Visual Studio Community 2015 (Update 1 and 2)
  • CMake 3.2.3

Acknowledgments

A starting point for this work was this blog's post on how to build log4cxx with Visual Studio 10.

About

Helpers to use log4cxx on Visual Studio 2019 with 142 toolkit


Languages

Language:C 51.5%Language:C++ 26.2%Language:Makefile 10.2%Language:HTML 5.2%Language:Shell 2.7%Language:M4 1.9%Language:CMake 0.8%Language:Perl 0.4%Language:Roff 0.3%Language:Assembly 0.2%Language:CSS 0.1%Language:Awk 0.1%Language:Python 0.1%Language:XSLT 0.1%Language:Batchfile 0.1%Language:Inno Setup 0.0%Language:Java 0.0%Language:PHP 0.0%Language:PowerShell 0.0%