Visual studio 2013 在visual studio 2013下构建log4cxx
我正在尝试在Visual Studio 2013下构建log4cxx版本0.10.0。我已经完成了中指定的所有修复 但是,在尝试创建log4cxx.lib时,它现在在链接阶段失败,出现以下错误:Visual studio 2013 在visual studio 2013下构建log4cxx,visual-studio-2013,log4cxx,Visual Studio 2013,Log4cxx,我正在尝试在Visual Studio 2013下构建log4cxx版本0.10.0。我已经完成了中指定的所有修复 但是,在尝试创建log4cxx.lib时,它现在在链接阶段失败,出现以下错误: unresolved external symbol __InterlockedIncrement referenced in function _apr_atomic_inc32@4 unresolved external symbol __InterlockedExchangeAdd referen
unresolved external symbol __InterlockedIncrement referenced in function _apr_atomic_inc32@4
unresolved external symbol __InterlockedExchangeAdd referenced in function _apr_atomic_add32@8
unresolved external symbol __InterlockedExchange referenced in function _apr_atomic_set32@8
unresolved external symbol __InterlockedDecrement referenced in function _apr_atomic_dec32@4
unresolved external symbol __InterlockedCompareExchange referenced in function _apr_atomic_cas32@12
根据MSDN,这些函数应该在kernel32.lib中,我已经将其添加到链接器中,但没有效果。查看ht elib,它似乎包含\u InterlockedIncrement
(单下划线)和\u imp\u InterlockedIncrement
有人知道我能做些什么让它工作吗
此外,中建议的修复不会产生任何不同链接错误的原因是APR(Apache Portable Runtime)库 在文件
atomic\win32\apr\u atomic.c
中,有对各种互锁函数的调用,形式如下:
#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED)
return InterlockedIncrement(mem) - 1;
#else
return ((apr_atomic_win32_ptr_fn)InterlockedIncrement)(mem) - 1;
#endif
其中apr\u atomic\u win32\u ptr\u fn
定义为
typedef WINBASEAPI apr_uint32_t (WINAPI * apr_atomic_win32_ptr_fn)
(apr_uint32_t volatile *);
当编译器构建32位可执行文件时,使用第二个调用。此强制转换会导致编译器无法将InterlockedIncrement
识别为内置项,并生成对\uuuInterlockedIncrement()
的调用,而不是预期的内在项
作为一个临时修复,我已经编辑了调用,以使用与64位版本相同的调用。关于log4cxx,以下内容适用于我:
下面的过程是在VS2013下为32位和64位构建构建Log4CXX的完整过程。请注意,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
中的文件。见下文apr\atomic\win32\apr\u atomic.c
已定义(_M_IA64)|已定义(_M_AMD64))
替换为已定义(_M_IA64)|已定义(_MSC_VER==1800))
这只是一个临时的解决方案,但它是有效的apr util
。
include\apu.hw
中,将apu HAVE\u APR\u ICONV
更改为0include\apr\u ldap.hw
中,将更改apr\u的ldap
定义为0apache-log4cxx-0.10.0\projects\log4cxx.dsw
加载到Visual Studio 2013中。系统将提示您升级项目。接受,然后等待转换完成。这将创建log4cxx.sln
,您下次打开项目时应该使用它Build->Configuration Manager
。为发布和调试的log4cxx
创建x64项目上下文。选中这些项目的“生成”框log4cxx
项目,然后选择properties
。
Debug/All platforms
配置设置配置属性/General/Target name
以“\u d”作为文件名的结尾Linker/All Options/Output File
设置为以“\u 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);
---
>
diff-r.\archives\apache-log4cxx-0.10.0/src/main/cpp/loggingevent.cpp.\build\u official\u 2\apache-log4cxx-0.10.0/src/main/cpp/loggingevent.cpp
127c127
KeySet LoggingEvent::getMDCKeySet()常量
129c129
键集;
188c188
KeySet LoggingEvent::getPropertyKeySet()常量
190c190
键集;
diff-r.\archives\apache-log4cxx-0.10.0/src/main/cpp/propertiespatternconverter.cpp.\build\u official\u 2\apache-log4cxx-0.10.0/src/main/cpp/propertiespatternconverter.cpp
62c62
getMDCKeySet());
---
>按键集按键集(事件->getMDCKeySet());
64c64
for(KeySet::const_迭代器iter=KeySet.begin();
diff-r.\archives\apache-log4cxx-0.10.0/src/main/cpp/xmlayout.cpp.\build\u official\u 2\apache-log4cxx-0.10.0/src/main/cpp/xmlayout.cpp
104105C104105
getPropertyKeySet());
getMDCKeySet());
---
>键集propertySet(事件->getPropertyKeySet());
>按键集按键集(事件->getMDCKeySet());
109c109
for(KeySet::const_迭代器i=KeySet.begin();
123c123
for(KeySet::const_迭代器i2=propertySet.begin();
diff-r.\archives\apache-log4cxx-0.10.0/src/main/include/log4cxx/asyncappender.h.\build\u official\u 2\apache-log4cxx-0.10.0/src/main/include/lo