本文一共包含了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

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

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

 

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

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

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

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

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

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

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

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

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

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

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

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

8、进入D:\log4cxx_compile\apr-util\include中并找到apu.hw文件,如下图:
在vs2010中编译log4cxx-0.10.0详细方法(从下载、编译、解决错误详细介绍)
 
9、用Notepad++ 打开apu.hw文件(记事本也可以)
在vs2010中编译log4cxx-0.10.0详细方法(从下载、编译、解决错误详细介绍)

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

#define APU_HAVE_APR_ICONV 1

改为

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

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

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

 

打开工程会提示转换:

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

 

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

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

 

12、将 log4cxx 设置为启动项.

设置前:

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

 

设置后:

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

13. 开始编译.log4cxx 

 

 

 

 

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

出现

 

4>D:\log4cxx_compile\apache-log4cxx-0.10.0\src\main\include\log4cxx/spi/loggingevent.h(155): error C2252: 只能在命名空间范围内显式实例化模板
在vs2010中编译log4cxx-0.10.0详细方法(从下载、编译、解决错误详细介绍)
 
a) 双击 "输出" 窗口中的错误行, 此时会在 "代码窗口" 中出现错误的位置.如下图:
在vs2010中编译log4cxx-0.10.0详细方法(从下载、编译、解决错误详细介绍)
b) 选择 LOG4CXX_LIST_DEF, 按键盘 F12, 此时会跳转到该宏的定义,如下图:
在vs2010中编译log4cxx-0.10.0详细方法(从下载、编译、解决错误详细介绍)

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

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

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)

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

 

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

 

出现

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

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

 

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

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

 

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

 出现 '无法解析的外部符号 xxx' 等错误.

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

 

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

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

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

 

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

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

 

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

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

 

编译成功后:

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

 

到此log4cxx编译就完成了。

posted on 2014-09-16 13:34  jason-chen  阅读(473)  评论(0编辑  收藏  举报