以下步骤是在VS2013下构建Log4CXX的完整过程,适用于32位和64位版本。请注意,32位版本只进行了轻微测试,而64位版本进行了稍微更多的测试(即,这是我们正在使用的版本)。
- 下载
apache-log4cxx-0.10.0.zip
,apr-x.y.z-win32.src.zip
和apr-util-1.5.4-win32.src.zip
,其中x
,y
和z
是最新版本。
- 将内容提取到共享目录中。
- 重命名
apr-x.y.z
和 apr-utls-x.y.z
以去掉版本号。
- 对
log4cxx
文件中的补丁进行应用。请参见下面的步骤。
对于32位版本,请在apr\atomic\win32\apr_atomic.c
中打补丁。
使用defined(_M_IA64) || defined(_M_AMD64))
替换所有出现的位置,并改为defined(_M_IA64) || defined(_M_AMD64) || (_MSC_VER == 1800))
这只是一个临时修复,但它有效。
- 运行
apache-log4cxx-0.10.0\configure.bat
。
- 打补丁
apr-util
。
- 在
include\apu.hw
中,将APU_HAVE_APR_ICONV
定义为0。
- 在
include\apr_ldap.hw
中,将APR_HAS_LDAP
定义为0。
- 将
apache-log4cxx-0.10.0\projects\log4cxx.dsw
加载到Visual Studio 2013中。您将被提示升级项目。接受并等待转换完成。这将创建log4cxx.sln
,您应该在下次打开项目时使用它
- 选择菜单选项
Build->Configuration Manager
。为log4cxx
创建x64项目上下文,包括发布和调试。检查这些项目的构建框。
- 升级所需的项目。上一步将导致所有其他项目都需要升级。右键单击“解决方案资源管理器”中的项目,然后选择
Upgrade VC++ compiler ...
。
- 如果您想让调试库具有与发布不同的文件名,请右键单击
log4cxx
项目,然后选择属性
。
- 选择
Debug / All platforms
配置设置。
- 将
Configuration Properties / General / Target name
设置为以“_d”作为文件名结尾。
- 将
Linker / All Options / Output File
设置为以“_d”作为文件名结尾。
- 将
Linker / All Options / Import Library
设置为以“_d”作为文件名结尾。
- 在菜单
Build -> Configuration Manager
中选择适当的活动解决方案配置和平台。
- 构建项目。
以下是
log4cxx
所需的补丁。
diff -r .\archives\apache-log4cxx-0.10.0/src/main/cpp/loggingevent.cpp .\build_official_2\apache-log4cxx-0.10.0/src/main/cpp/loggingevent.cpp
127c127
< LoggingEvent::KeySet LoggingEvent::getMDCKeySet() const
---
> KeySet LoggingEvent::getMDCKeySet() const
129c129
< LoggingEvent::KeySet set;
---
> KeySet set;
188c188
< LoggingEvent::KeySet LoggingEvent::getPropertyKeySet() const
---
> KeySet LoggingEvent::getPropertyKeySet() const
190c190
< LoggingEvent::KeySet set;
---
> KeySet set;
diff -r .\archives\apache-log4cxx-0.10.0/src/main/cpp/propertiespatternconverter.cpp .\build_official_2\apache-log4cxx-0.10.0/src/main/cpp/propertiespatternconverter.cpp
62c62
< LoggingEvent::KeySet keySet(event->getMDCKeySet());
---
> KeySet keySet(event->getMDCKeySet());
64c64
< for(LoggingEvent::KeySet::const_iterator iter = keySet.begin();
---
> for(KeySet::const_iterator iter = keySet.begin();
diff -r .\archives\apache-log4cxx-0.10.0/src/main/cpp/xmllayout.cpp .\build_official_2\apache-log4cxx-0.10.0/src/main/cpp/xmllayout.cpp
104,105c104,105
< LoggingEvent::KeySet propertySet(event->getPropertyKeySet());
< LoggingEvent::KeySet keySet(event->getMDCKeySet());
---
> KeySet propertySet(event->getPropertyKeySet());
> KeySet keySet(event->getMDCKeySet());
109c109
< for (LoggingEvent::KeySet::const_iterator i = keySet.begin();
---
> for (KeySet::const_iterator i = keySet.begin();
123c123
< for (LoggingEvent::KeySet::const_iterator i2 = propertySet.begin();
---
> for (KeySet::const_iterator i2 = propertySet.begin();
diff -r .\archives\apache-log4cxx-0.10.0/src/main/include/log4cxx/asyncappender.h .\build_official_2\apache-log4cxx-0.10.0/src/main/include/log4cxx/asyncappender.h
52a53
> LOG4CXX_LIST_DEF(LoggingEventList, log4cxx::spi::LoggingEventPtr);
197c198
< LOG4CXX_LIST_DEF(LoggingEventList, log4cxx::spi::LoggingEventPtr);
---
>
diff -r .\archives\apache-log4cxx-0.10.0/src/main/include/log4cxx/helpers/bytearrayinputstream.h .\build_official_2\apache-log4cxx-0.10.0/src/main/include/log4cxx/helpers/bytearrayinputstream.h
38a39
> LOG4CXX_LIST_DEF(ByteList, unsigned char);
42c43
< LOG4CXX_LIST_DEF(ByteList, unsigned char);
---
>
diff -r .\archives\apache-log4cxx-0.10.0/src/main/include/log4cxx/helpers/bytearrayoutputstream.h .\build_official_2\apache-log4cxx-0.10.0/src/main/include/log4cxx/helpers/bytearrayoutputstream.h
40a41
> LOG4CXX_LIST_DEF(ByteList, unsigned char);
44c45
< LOG4CXX_LIST_DEF(ByteList, unsigned char);
---
>
diff -r .\archives\apache-log4cxx-0.10.0/src/main/include/log4cxx/helpers/simpledateformat.h .\build_official_2\apache-log4cxx-0.10.0/src/main/include/log4cxx/helpers/simpledateformat.h
45a46
> LOG4CXX_LIST_DEF(PatternTokenList, log4cxx::helpers::SimpleDateFormatImpl::PatternToken*);
78c79
< LOG4CXX_LIST_DEF(PatternTokenList, log4cxx::helpers::SimpleDateFormatImpl::PatternToken*);
---
>
diff -r .\archives\apache-log4cxx-0.10.0/src/main/include/log4cxx/helpers/socketoutputstream.h .\build_official_2\apache-log4cxx-0.10.0/src/main/include/log4cxx/helpers/socketoutputstream.h
35c35
<
---
> LOG4CXX_LIST_DEF(ByteList, unsigned char);
53c53
< LOG4CXX_LIST_DEF(ByteList, unsigned char);
---
>
diff -r .\archives\apache-log4cxx-0.10.0/src/main/include/log4cxx/net/sockethubappender.h .\build_official_2\apache-log4cxx-0.10.0/src/main/include/log4cxx/net/sockethubappender.h
105c105
<
---
> LOG4CXX_LIST_DEF(ObjectOutputStreamList, log4cxx::helpers::ObjectOutputStreamPtr);
115c115
< LOG4CXX_LIST_DEF(ObjectOutputStreamList, log4cxx::helpers::ObjectOutputStreamPtr);
---
>
diff -r .\archives\apache-log4cxx-0.10.0/src/main/include/log4cxx/net/telnetappender.h .\build_official_2\apache-log4cxx-0.10.0/src/main/include/log4cxx/net/telnetappender.h
67c67,69
< class LOG4CXX_EXPORT TelnetAppender : public AppenderSkeleton
---
> typedef log4cxx::helpers::SocketPtr Connection;
> LOG4CXX_LIST_DEF(ConnectionList, Connection);
> class LOG4CXX_EXPORT TelnetAppender : public AppenderSkeleton
134,135d135
< typedef log4cxx::helpers::SocketPtr Connection;
< LOG4CXX_LIST_DEF(ConnectionList, Connection);
diff -r .\archives\apache-log4cxx-0.10.0/src/main/include/log4cxx/patternlayout.h .\build_official_2\apache-log4cxx-0.10.0/src/main/include/log4cxx/patternlayout.h
326a327,328
> LOG4CXX_LIST_DEF(LoggingEventPatternConverterList, log4cxx::pattern::LoggingEventPatternConverterPtr);
> LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);
337c339
< LOG4CXX_LIST_DEF(LoggingEventPatternConverterList, log4cxx::pattern::LoggingEventPatternConverterPtr);
---
>
343c345
< LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);
---
>
diff -r .\archives\apache-log4cxx-0.10.0/src/main/include/log4cxx/rolling/rollingpolicybase.h .\build_official_2\apache-log4cxx-0.10.0/src/main/include/log4cxx/rolling/rollingpolicybase.h
44a45,46
> LOG4CXX_LIST_DEF(PatternConverterList, log4cxx::pattern::PatternConverterPtr);
> LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);
60c62
< LOG4CXX_LIST_DEF(PatternConverterList, log4cxx::pattern::PatternConverterPtr);
---
>
66c68
< LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);
---
>
diff -r .\archives\apache-log4cxx-0.10.0/src/main/include/log4cxx/spi/loggingevent.h .\build_official_2\apache-log4cxx-0.10.0/src/main/include/log4cxx/spi/loggingevent.h
54a55
> LOG4CXX_LIST_DEF(KeySet, LogString);
155c156
< LOG4CXX_LIST_DEF(KeySet, LogString);
---
>