Yes, I wanted to have a uniform logging library for all my dev projects, after looking at log4cpp / log4cplus / log4cxx, I end up choosing log4cxx simply its obvious ability to use a external config file (just like log4j), which log4cpp and log4cplus is missing from.
Unfortunately using the library in Win32 is less then obvious.
The official site at http://logging.apache.org/log4cxx/ , provides “log4cxx-0.9.7″ but it comes with a warning: “At this point, log4cxx-0.9.7 is substantially out of date, has known serious deficiencies that have been resolved in the CVS, and should be avoided for new code.” *_*
After digging around, I downloaded the HEAD version, which suppose to be version 0.10.0, the source does not have a Visual Studio Project files, reading the installation instructions it says that I need ANT and bunch of other stuff to get it to build… fine… I can tolerate that…
After 3 hours of downloading and install the required package with exactly the same version of files required as stated in the installation guide and I figure, finally the moment of truth! (actually, later I found out its actually a beginning of another few hours of frustrations!)
The ant build went on, and its throwing all kind of error, and finally display a fail build status, I don’t understands, all the util are exactly the same version as request in the installation guide. After a few hours of search and debug, reading through the build script, nothing seems to help. Then a wild idea come up, “was it because there is a space in the folder name?“, I was building in my desktop, which gives a directory “C:\Document and Setting…” (you get the idea), I move the source folder to C:\tmp and start ant build there, and it runs!
Rebuilding with ant build, and it complain “Assertion failed, hunk …“, ok… I recognize that, it because of the sed util can’t handle CRLF in win32, so I went on writing a script, and change all CRLF in *.patch file into CR, that got rid of the error.
Rebuilding with ant build, building going on… splash BUILD FAILED! Apparently the unit test failed, did some search in the mailing list, nothing comes up…
Ok… I figure since ant build supports an option to build a VS2005 project file, which can be open with VS2005, it might be a better idea then relying on the Ant tool for the build.
Building the VS2005 project file gives a BUILD SUCCESS!
I open up the generated project file with VS2005, and start the compilation process, everything seems fine, until at the last bit of the compilation it splat me “fatal error LNK1104: cannot open file ‘.obj’ “. WTF is “.obj” ? I look into the vs project properties, no such thing in linker, and the path for link library is properly encase with double quote as well, every setting seems fine, but the darn library just wont compile… *_*
Ok… fine… ant tool still have another options to build a VC6 project file, oh hell why not? I’ve come this far… VC6 project file generation with ant tool yield BUILD SUCCESS (yes.. again). Load it up with VC6 and compile… Pronto! Success! I’ve finally got log4cxx binary!
I open up the VC6 project file with VS2005, and upgrade it to VS2005 compatible, and with my finger cross I hit compile… and it WORKS too!
Only problem now is that the ant build tool only generate a vs project file once per configuration, that mean if I want Debug Static library I have to build one file, Release Static library I have to build another, Debug Dynamic Link Library another one… so on and so forth…
I went on and build all the VC6 project file, rename it each time, since the build tool will overwrite its only use the same file name.
I upgrade all the VS6 project files to VS2005 compatible, and later hand edit them, so that it all fit nicely in a single solution, that will build both the Static and Dynamic version of log4cxx, Debug / Release build.
By the time I did that, its already the 4th day since I started of this log4cxx journey… pain pain pain… but it all came through…
VC6 Project + Source for log4cxx v0.10.0 (out dated May 2007)
(I’ve not try to compile this on a VC6 before, the purpose of me making this available is to allow you to convert the project file to other version of VS if you’re not using VS2005)
VC6 Binary Build + Source of log4cxx v0.10.0 (updated June 2008)
VC2008 Binary Build + Source of log4cxx v0.10.0 (updated June 2008)
(if you use other version of MSVC, then just get the VC6 package and upgrade the project files to your MSVC version)
Now please say thank you : )
To use the static link log4cxx library, the macro LOG4CXX_STATIC MUST be defined in your projects preprocessor, otherwise your compilation will suffer unresolved linking error.