编译log4cxx

    花了一晚上时间编译log4cxx, 总算通过了,这鸟工具,整S我了。
  
    使用log4cxx的版本为0.97 , OS为Fedora 6.   在make的过程中,首先碰到的问题就是:
    ../include/log4cxx/xml/domconfigurator.h:249: error: extra qualification
      'log4cxx::xml::DOMConfigurator::' on member 'subst'

      以上问题花了近二个小时,才找到答案, 答案见下:

   
Index: include/log4cxx/xml/domconfigurator.h
===================================================================
--- include/log4cxx/xml/domconfigurator.h (revision 384243)
+++ include/log4cxx/xml/domconfigurator.h (working copy)
@@ -246,7 +246,7 @@
                 protected:
                         static LogString getAttribute(apr_xml_elem*,
                             const std::string& attrName);
-                        LogString DOMConfigurator::subst(const LogString& value);
+                       LogString subst(const LogString& value);   //要在源代码中把以上函数声明改成这句
 
                 protected:
                         helpers::Properties props;



   然后,编译到 /tests/src/util/filter.cpp 时,提示“‘RegEx’ 在此作用域中尚未声明”
   进入到filter.cpp文件中,看到该文件使用的是boost库中的regex功能。
  
#include <boost/regex.hpp>
#include 
"filter.h"

using namespace log4cxx;
using namespace log4cxx::helpers;
using namespace boost;

String Filter::merge(
const String& pattern, const String& inconst String& fmt)
{
        USES_CONVERSION;
        std::
string convPattern = T2A(pattern.c_str());
        std::
string convIn = T2A(in.c_str());
        std::
string convFmt = T2A(fmt.c_str());

        std::
string result = RegEx(convPattern).Merge(convIn, convFmt);
        
return A2T(result.c_str());

}

    首先想到的是: gcc的时候“-lboost_regex”没有添加,在Makfile.in中添加编译选项:"-lboost_regex",还是出现该错误。

    最后,查看boost库源代码,发现RegEx函数定义在cregex.hpp中,而不是regex.hpp中,可能是boost库已经更新(把RegEx函数移到cregex.hpp中定义),而log4cxx却还是默认使用旧boost库的原因。

   这个错误更改一下头文件编译就OK了。
     
#include <boost/cregex.hpp>

以上两个错误,花起来解决的时间都要4个小时。真是无语了。。。
posted @ 2008-01-04 22:46  shipfi  阅读(1457)  评论(0编辑  收藏  举报