在 Visual Studio 2013 下构建 log4cxx

Sim*_*lan 3 log4cxx visual-studio-2013

我正在尝试在 Visual Studio 2013 下构建 log4cxx 版本 0.10.0。我已完成在 vs 2010 c++ 中构建 log4cxx中指定的所有修复。

但是,当尝试创建 log4cxx.lib 时,它现在在链接阶段失败,并出现以下错误:

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
Run Code Online (Sandbox Code Playgroud)

根据MSDN,这些函数应该在kernel32.lib中,我已将其添加到链接器中,但没有效果。查看 ht elib,这似乎包含_InterlockedIncrement(单下划线)和_imp_InterlockedIncrement

有谁知道我能做些什么来让它工作?

此外, Building log4cxx with VS 2012 on Windows 7中建议的修复 不会产生任何不同

Sim*_*lan 5

以下过程是在 VS2013 下构建 Log4CXX 的完整过程,适用于 32 位和 64 位构建。请注意,32 位版本经过了非常简单的测试,64 位版本经过了稍微更广泛的测试(IE,这是我们正在使用的版本)。

\n\n
    \n
  1. 下载apache-log4cxx-0.10.0.zip、、 、apr-x.y.z-win32.src.zip和是最新版本。apr-util-1.5.4-win32.src.zipxyz
  2. \n
  3. 将内容提取到共享目录。
  4. \n
  5. 重命名apr-x.y.zapr-utls-x.y.z删除版本号。
  6. \n
  7. 将补丁应用于log4cxx. 见下文。
  8. \n
  9. 对于 32 位版本,修补apr\\atomic\\win32\\apr_atomic.c.

    \n\n
      \n
    1. 所有出现的替换defined(_M_IA64) || defined(_M_AMD64))defined(_M_IA64) || defined(_M_AMD64) || (_MSC_VER == 1800))

      \n\n

      这实际上只是一个临时修复,但它确实有效。

    2. \n
  10. \n
  11. 跑步apache-log4cxx-0.10.0\\configure.bat
  12. \n
  13. 补丁apr-util。\n
      \n
    1. 在 中include\\apu.hw,更改APU_HAVE_APR_ICONV为定义为 0。
    2. \n
    3. 在 中include\\apr_ldap.hw,更改APR_HAS_LDAP为定义为 0。
    4. \n
  14. \n
  15. 加载apache-log4cxx-0.10.0\\projects\\log4cxx.dsw到 Visual Studio 2013。系统将提示您升级项目。接受并等待转换完成。这将创建log4cxx.sln您下次打开项目时应该使用的
  16. \n
  17. 选择菜单选项Build->Configuration Managerlog4cxx为发布和调试创建 x64 项目上下文。检查这些项目的构建框。
  18. \n
  19. 根据需要升级项目。上一步将导致所有其他项目都需要此操作。\xe2\x80\x8b 在解决方案资源管理器中右键单击该项目并选择Upgrade VC++ compiler ...
  20. \n
  21. 如果您希望调试库具有与版本不同的文件名,请右键单击该log4cxx项目,然后选择properties。\n
      \n
    1. 选择Debug / All platforms配置设置。
    2. \n
    3. 设置Configuration Properties / General / Target name为以“_d”作为文件名结尾。
    4. \n
    5. 设置Linker / All Options / Output File为以“_d”作为文件名结尾。
    6. \n
    7. 将 \xe2\x80\x8b设置Linker / All Options / Import Library为以“_d”作为文件名结尾。
    8. \n
  22. \n
  23. 在菜单中选择适当的活动解决方案配置和平台Build -> Configuration manager
  24. \n
  25. 构建项目。
  26. \n
\n\n
\n\n

下面是log4cxx.

\n\n
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\n127c127\n< LoggingEvent::KeySet LoggingEvent::getMDCKeySet() const\n---\n> KeySet LoggingEvent::getMDCKeySet() const\n129c129\n<         LoggingEvent::KeySet set;\n---\n>         KeySet set;\n188c188\n< LoggingEvent::KeySet LoggingEvent::getPropertyKeySet() const\n---\n> KeySet LoggingEvent::getPropertyKeySet() const\n190c190\n<         LoggingEvent::KeySet set;\n---\n>         KeySet set;\ndiff -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\n62c62\n<       LoggingEvent::KeySet keySet(event->getMDCKeySet());\n---\n>       KeySet keySet(event->getMDCKeySet());\n64c64\n<       for(LoggingEvent::KeySet::const_iterator iter = keySet.begin();\n---\n>       for(KeySet::const_iterator iter = keySet.begin();\ndiff -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\n104,105c104,105\n<             LoggingEvent::KeySet propertySet(event->getPropertyKeySet());\n<             LoggingEvent::KeySet keySet(event->getMDCKeySet());\n---\n>             KeySet propertySet(event->getPropertyKeySet());\n>             KeySet keySet(event->getMDCKeySet());\n109c109\n<                 for (LoggingEvent::KeySet::const_iterator i = keySet.begin();\n---\n>                 for (KeySet::const_iterator i = keySet.begin();\n123c123\n<             for (LoggingEvent::KeySet::const_iterator i2 = propertySet.begin();\n---\n>             for (KeySet::const_iterator i2 = propertySet.begin();\ndiff -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\n52a53\n>       LOG4CXX_LIST_DEF(LoggingEventList, log4cxx::spi::LoggingEventPtr);\n197c198\n<                 LOG4CXX_LIST_DEF(LoggingEventList, log4cxx::spi::LoggingEventPtr);\n---\n>                 \ndiff -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\n38a39\n>         LOG4CXX_LIST_DEF(ByteList, unsigned char);\n42c43\n<               LOG4CXX_LIST_DEF(ByteList, unsigned char);\n---\n>               \ndiff -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\n40a41\n>         LOG4CXX_LIST_DEF(ByteList, unsigned char);\n44c45\n<                  LOG4CXX_LIST_DEF(ByteList, unsigned char);\n---\n>                  \ndiff -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\n45a46\n>         LOG4CXX_LIST_DEF(PatternTokenList, log4cxx::helpers::SimpleDateFormatImpl::PatternToken*);\n78c79\n<                   LOG4CXX_LIST_DEF(PatternTokenList, log4cxx::helpers::SimpleDateFormatImpl::PatternToken*);\n---\n>                   \ndiff -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\n35c35\n< \n---\n>               LOG4CXX_LIST_DEF(ByteList, unsigned char);\n53c53\n<                         LOG4CXX_LIST_DEF(ByteList, unsigned char);\n---\n>                         \n\ndiff -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\n105c105\n< \n---\n>               LOG4CXX_LIST_DEF(ObjectOutputStreamList, log4cxx::helpers::ObjectOutputStreamPtr);\n115c115\n<                         LOG4CXX_LIST_DEF(ObjectOutputStreamList, log4cxx::helpers::ObjectOutputStreamPtr);\n---\n>                         \ndiff -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\n67c67,69\n<         class LOG4CXX_EXPORT TelnetAppender : public AppenderSkeleton\n---\n>           typedef log4cxx::helpers::SocketPtr Connection;\n>           LOG4CXX_LIST_DEF(ConnectionList, Connection);\n>           class LOG4CXX_EXPORT TelnetAppender : public AppenderSkeleton\n134,135d135\n<                         typedef log4cxx::helpers::SocketPtr Connection;\n<                         LOG4CXX_LIST_DEF(ConnectionList, Connection);\ndiff -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\n326a327,328\n>       LOG4CXX_LIST_DEF(LoggingEventPatternConverterList, log4cxx::pattern::LoggingEventPatternConverterPtr);\n>       LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);\n337c339\n<                 LOG4CXX_LIST_DEF(LoggingEventPatternConverterList, log4cxx::pattern::LoggingEventPatternConverterPtr);\n---\n>                 \n343c345\n<                 LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);\n---\n>                 \n\ndiff -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\n44a45,46\n>       LOG4CXX_LIST_DEF(PatternConverterList, log4cxx::pattern::PatternConverterPtr);\n>       LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);\n60c62\n<           LOG4CXX_LIST_DEF(PatternConverterList, log4cxx::pattern::PatternConverterPtr);\n---\n>           \n66c68\n<           LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);\n---\n>           \ndiff -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\n54a55\n>               LOG4CXX_LIST_DEF(KeySet, LogString);\n155c156\n<                         LOG4CXX_LIST_DEF(KeySet, LogString);\n---\n>       \n
Run Code Online (Sandbox Code Playgroud)\n