Click here to Skip to main content
13,147,376 members (28,283 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


9 bookmarked
Posted 12 Nov 2012

How to build log4cxx with Visual Studio 2010

, 12 Nov 2012
Rate this:
Please Sign up or sign in to vote.
This article should help you building log4cxx with Visual Studio 2010


This article is a step-by-step tutorial about building the logging framework log4cxx from Apache based on my own experience. I've used version 0.10.0 of log4cxx when writing this article. 


I tried to build log4cxx on many different ways like using the source out of the CVS repository and so on but with none of these ways I could get a working log4cxx library. I got a lot of help and ideas from another blog post located here. A big thank you to the author! I also posted this "article" as an answer on and you can find it here

Let's get started ... 

  1. Download the latest log4cxx package from here
  2. Download apr and apr-util ZIP packages from here
  3. Extract log4cxx, apr und apr-util to the same directory
  4. Rename the apr_VERSION and apr-util_VERSION folder to apr and apr-util resulting in a directory with three folder: apache-log4cxx-0.10.0, apr and apr-util 
  5. Change into the log4cxx directory and execute configure.bat
  6. Change to apr-util/include direcotry and open apu-hw in a texteditor of your choice
  7. Find the entry #define APU_HAVE_APR_ICONV, set it to 0 and save the file 
  8. Open apr_ldap.hw from the same directory and find the entry #define APR_HAS_LDAP, set it to 0 and save the file, too  
  9. Change to log4cxx/projects directory and open log4cxx.dsw with VS2010. Answer the converting prompts of VS2010 with yes/ok for each project (apr, apr-util, log4cxx, xml) 

OK ... if you hit build (F6) now then you will see around 2000 errors and that is where the interesting and hard part starts ... if it compiles fine then you're damn lucky guy! Wink | ;)  

  • Ctrl+F and find each entry of the "LOG4CXX_LIST_DEF" macro. You have to move these entries out of its related class and right before the same class. Sometimes you need to move a typedef too or add the class right before the macro. 

Some examples which should help you to understand what I mean:

// telnetadapter.h
typedef log4cxx::helpers::SocketPtr Connection;
LOG4CXX_LIST_DEF(ConnectionList, Connection);
class LOG4CXX_EXPORT TelnetAppender : public AppenderSkeleton

// appender.h
class Appender;
LOG4CXX_LIST_DEF(AppenderList, AppenderPtr);
class Layout;
typedef log4cxx::helpers::ObjectPtrT<Layout> LayoutPtr;
class LOG4CXX_EXPORT Appender :public virtual spi::OptionHandler

If the compiler complains about KeySet not being member of LoggingEvent, just remove the scope (since we moved the type to outside the class in the previous step, these types no longer are inside the class).


// old
LoggingEvent::KeySet set;
// new
KeySet set;     
  • If the compiler complains about insert_iterator not being in the namespace std, add #include <iterator> to the include section of the source file
  • Last but not least, right-click on log4cxx project and select Add References and select the other 3 projects as reference   

That's it ... I hope this article can help someone who's struggling with the same problem! 


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Severin Friede
Germany Germany
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionVisual Studio 2015 Pin
deatc15-Nov-16 6:46
memberdeatc15-Nov-16 6:46 
QuestionLink error Solution? Pin
Member 1223033929-Dec-15 6:36
memberMember 1223033929-Dec-15 6:36 
QuestionLog4Cxx link error Pin
JeCheng11-Jul-15 7:11
memberJeCheng11-Jul-15 7:11 
AnswerRe: Log4Cxx link error Pin
Member 116527208-Dec-15 8:44
memberMember 116527208-Dec-15 8:44 
AnswerRe: Log4Cxx link error Pin
Member 1223033926-Dec-15 23:41
memberMember 1223033926-Dec-15 23:41 
Questionstd::length_error in Debug builds Pin
tivadj31-Mar-14 7:20
membertivadj31-Mar-14 7:20 
QuestionDanke Pin
Member 999955018-Mar-14 3:12
memberMember 999955018-Mar-14 3:12 
QuestionWhat about c++ builder ? Pin
Member 997458230-Jul-13 2:29
memberMember 997458230-Jul-13 2:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170915.1 | Last Updated 12 Nov 2012
Article Copyright 2012 by Severin Friede
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid