您的位置:首页 > 其它

在vs2010中编译log4cxx-0.10.0详细方法(从下载、编译、解决错误详细介绍

2014-06-13 16:12 841 查看
本文一共包含了17个步骤,按照下面的步骤就可以完成vs2010中编译log4cxx的工作了。

1. 下载 log4cxx 以及 apr 和 apr-util 源码:

a) http://www.apache.org/dyn/closer.cgi/logging/log4cxx/0.10.0/apache-log4cxx-0.10.0.zip

b) http://archive.apache.org/dist/apr/apr-1.2.11-win32-src.zip

c) http://archive.apache.org/dist/apr/apr-util-1.2.10-win32-src.zip





2. 将 3 个压缩包解压到同一个目录.如下图:





3. 将 apr-1.2.11
重命名
为 apr, 将 apr-util-1.2.10 重命名为 apr-util.如下图:





4、打开cmd窗口,如下图所示:





5、在4中输入:cd D:\log4cxx_compile\apache-log4cxx-0.10.0 回车

然后输入:d: 回车后 切换至 apache-log4cxx-0.10.0 目录





6、在5中输入:configure.bat 回车







7. 在6的基础下dos窗口下继续输入:configure-aprutil.bat 回车





8、进入D:\log4cxx_compile\apr-util\include中并找到apu.hw文件,如下图:




9、用Notepad++ 打开apu.hw文件(记事本也可以)




手动修改apr-util\include\apu.hw 里的内容

#define APU_H***E_APR_ICONV 1
改为

#define APU_H***E_APR_ICONV 0




10. 使用VS2010打开apache-log4cxx-0.10.0\projects 下的
log4cxx.dsw







打开工程会提示转换:







11、转换好后工程如下图:







12、将 log4cxx 设置为启动项.

设置前:







设置后:





13. 开始编译.log4cxx










出现



4>D:\log4cxx_compile\apache-log4cxx-0.10.0\src\main\include\log4cxx/spi/loggingevent.h(155): error C2252: 只能在命名空间范围内显式实例化模板




a) 双击 "输出" 窗口中的错误行, 此时会在 "代码窗口" 中出现错误的位置.如下图:





b) 选择 LOG4CXX_LIST_DEF, 按键盘 F12, 此时会跳转到该宏的定义,如下图:




c) 将

#define LOG4CXX_LIST_DEF(N, T) \

template class LOG4CXX_EXPORT std::allocator<T>; \

template class LOG4CXX_EXPORT std::vector<T>; \

typedef std::vector<T> N

替换为:

#define LOG4CXX_LIST_DEF(N, T) \

typedef std::vector<T> N





14、按照13修改后,重新编译
出现

2>network_io\unix\multicast.c(137): error C2079: “mip”使用未定义的struct “group_source_req”错误


双击第一行出错输出, 将 136 和 148 行的 #if MCAST_JOIN_SOURCE_GROUP 注释, 替换为 #if defined (group_source_req)







15、按照14修改后,重新编译


出现

'4>..\src\main\cpp\stringhelper.cpp(64): error C2039: “insert_iterator”: 不是“std”的成员' 等错误.







在该 .cpp 中(stringhelper.cpp) 加入头文件 #include<iterator>







16、按照15修改后,重新编译
出现 '无法解析的外部符号 xxx' 等错误.







将 apr, aprutil, xml 添加至 log4cxx 的引用中.(按照下面4副图的顺序操作)


















17. 选择重新生成解决方案.







编译成功后:





到此log4cxx编译就完成了。

转载:点击打开链接
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐