Apache Log4CXX is a logging framework for C++ patterned after Apache log4j. It also happens to be quite difficult to build on Windows if you are using Microsoft Windows SDK 1.0 (AKA Microsoft Platform SDK 6.0). If you are building software for Windows Vista or Windows Server 2008, or using Visual C++ 2008, you are using Windows SDK 1.0.

The reason Log4CXX 0.10.0 is hard to compile with Windows SDK 1.0 is a bug in APR 1.2.12 (the latest version available as of this writing) and a bug in Windows SDK 1.0 itself (a preprocessor redefinition due to including twice a header file). Here comes the recipe in case you want to build the stuff yourself:

  1. Download APR 1.2.12 and extract it. Rename to apr.
  2. Download APR Util 1.2.12 and extract it. Rename to apr-util.
  3. Download Log4CXX 0.10.0 and extract it
  4. Download GNU Sed and install it
  5. Open cmd.exe and run %PROGRAMFILES%Microsoft Visual Studio 9.0VCvcvarsall.bat
  6. Apply the apr-1.2.12-win32.patch patch to fix bug 40398 in APR 1.2.12 (this step is not needed if you are using APR 1.2.13)
  7. Apply the log4cxx-0.10.0-vc90-support.patch patch
  8. Enter directory apache-log4cxx-0.10.0
  9. Execute configure.bat
  10. Execute configure-aprutil.bat
  11. Open the log4cxx.dsw solution When asked to convert the solution to VC++9, click Yes to All.
  12. Right click on Solution log4cxx and select Build solution

3 Thoughts on “Building Log4CXX 0.10.0 on Windows

  1. Hi,

    I’m using the log4cxx.dll in my Eclipse RCP application, I have an another dll which been used by the RCP application, it is invoking the log4cxx call for logging.

    All works fine and I’able to get the logs(Thanks to Merc.. http://www.dreamcubes.com/blog/index.php?itemid=43#nucleus_cf). The only issue I find is, when I exit the RCP application, always the log4cxx dll is crashing. I tried multiple combination’s, but still I haven’t get it fixed. Any help would be greatly welcome.

    Thanks and Regards,

  2. How are the patches applied i.e. where should the patch file be copied and what is the command? I’m using GNU patch in DOS with no luck, getting the “can’t find file to patch..” message :/

    • Use “patch -p1 -d log4cxxdirectory” to make sure patch uses the right directory.

      In case GNU Patch crashes on Windows, convert the line endings (use tofrodos).

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Post Navigation