Thursday, December 6, 2012

Building log4cxx with VS 2012 on Windows 7

The ideas in this post come from here. The original post was for VS 2010. I'm posting for VS 2012 on Windows 7. The only important note is that _MSC_VER of VS 2012 is 1700.

Steps:
  1. Download log4cxx ZIP package from http://logging.apache.org/log4cxx/download.html, and extract its contents.
  2. Download latest available apr and apr-util ZIP package from http://apr.apache.org/download.cgi.
  3. unzip apr-1.x.y-win32-src.zip (manually extract the contents)
  4. rename apr-1.x.y apr (rename the folder)
  5. unzip apr-util-1.x.y-win32-src.zip (manually extract the contents)
  6. rename apr-util-1.x.y apr-util (rename the folder)
  7. cd apache-log4cxx-0.10.0
  8. configure
  9. Open apr-util\include\apu.hw.
  10. Find the line starting with "#define APU_HAVE_APR_ICONV".
  11. Change the constant to 0 and save the file.
  12. Open apr-util\include\apr_ldap.hw.
  13. Find the line starting with "#define APR_HAS_LDAP".
  14. Change the constant to 0 and save the file.
  15. Open VS 2012 and open project log4cxx.dsw.
  16. Click yes to whatever VS prompts you with (it has something to do with conversion).
  17. Once the projects have been converted, go to Header Files folder of log4cxx.
  18. Open log4cxx.h within VS.
  19. Change line containing "#if defined(_MSC_VER) && !defined(LOG4CXX_STATIC) && defined(LOG4CXX)" to "#if defined(_MSC_VER) && _MSC_VER < 1700 && !defined(LOG4CXX_STATIC) && defined(LOG4CXX)".
  20. Change line containing "#elif defined(_MSC_VER) && !defined(LOG4CXX_STATIC)" to "#elif defined(_MSC_VER) && _MSC_VER < 1700 && !defined(LOG4CXX_STATIC)".
  21. Build log4cxx.

2 comments:

  1. Did you actually got it to work? I compiled it but when i try simple examples it throws exceptions. I am running Windows 7 64bit

    ReplyDelete
  2. Hi, thanks for the tutorial, everything else compiles fine, but i m still seeing these 2 errors:
    3>domconfigurator.obj : error LNK2019: unresolved external symbol _apr_xml_parse_file@20 referenced in function "public: virtual void __thiscall log4cxx::xml::DOMConfigurator::doConfigure(class log4cxx::File const &,class log4cxx::helpers::ObjectPtrT &)" (?doConfigure@DOMConfigurator@xml@log4cxx@@UAEXABVFile@3@AAV?$ObjectPtrT@VLoggerRepository@spi@log4cxx@@@helpers@3@@Z)
    3>domconfigurator.obj : error LNK2019: unresolved external symbol _apr_xml_parser_geterror@12 referenced in function "public: virtual void __thiscall log4cxx::xml::DOMConfigurator::doConfigure(class log4cxx::File const &,class log4cxx::helpers::ObjectPtrT &)" (?doConfigure@DOMConfigurator@xml@log4cxx@@UAEXABVFile@3@AAV?$ObjectPtrT@VLoggerRepository@spi@log4cxx@@@helpers@3@@Z)
    3>.\Release\log4cxx.dll : fatal error LNK1120: 2 unresolved externals

    Can you help?

    ReplyDelete