编译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 &   in const  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个小时。真是无语了。。。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值