Vs2010编译log4cxx
最近准备改造log4cxx作为服务的日志系统,第一件事就是编译一套动态库备用。网上教程很多很乱,找到一篇适合自己的。
参考资料:https://m.jb51.net/softjc/277530.html
分享一下编译好的工程:链接: https://pan.baidu.com/s/1HBTMGhZ7UqjfPtWUl3-Sxw 提取码: wuyd
本文一共包含了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.输入:cdD:\log4cxx_compile\apache-log4cxx-0.10.0 回车
5. 输入:configure.bat回车
6. 进入D:\log4cxx_compile\apr-util\include中并找到apu.hw文件
7. 手动修改 apr-util\include\apu.hw里的内容
#define APU_HAVE_APR_ICONV1
改为
#define APU_HAVE_APR_ICONV0
8. 使用VS2010打开 apache-log4cxx-0.10.0\projects 下的 log4cxx.dsw
9. 开始编译.log4cxx
10 D:\log4cxx_compile\apache-log4cxx-0.10.0\src\main\include\log4cxx/spi/loggingevent.h(155):error C2252: 只能在命名空间范围内显式实例化模板
11. 选择 LOG4CXX_LIST_DEF, 按键盘 F12,此时会跳转到该宏的定义
12. 将
#define LOG4CXX_LIST_DEF(N, T) \
template class LOG4CXX_EXPORTstd::allocator<T>; \
template class LOG4CXX_EXPORTstd::vector<T>; \
typedef std::vector<T>N
替换为:
#define LOG4CXX_LIST_DEF(N, T) \
typedef std::vector<T>N
13. 按照12修改后,重新编译
出现
2>network_io\unix\multicast.c(137): errorC2079: “mip”使用未定义的struct”group_source_req”错误
双击第一行出错输出, 将 136 和 148 行的 #if MCAST_JOIN_SOURCE_GROUP 注释,替换为 #if defined (group_source_req)
14 .
出现
‘4>..\src\main\cpp\stringhelper.cpp(64):error C2039: “insert_iterator”: 不是”std”的成员’等错误
在该 .cpp中(stringhelper.cpp) 加入头文件#include<iterator>
15. 出现 ‘无法解析的外部符号 xxx’等错误.
将 apr, aprutil, xml添加至 log4cxx 的引用中.(按照下面4副图的顺序操作)