如何在Windows上构建Apache ActiveMQ-CPP(和APR)?

Bud*_*000 6 c++ activemq-classic apr activemq-cpp visual-studio

我正在尝试使用C++编写的一些功能来与位于Linux机器上的Apache ActiveMQ(本机使用JMS)进行通信.为了建立这种连接,我试图在我的Windows 7机器(开发机器)上设置Apache ActiveMQ-CPP,但我目前面临一些重大问题.

据我了解ActiveMQ的-CPP具有依赖于Apache的便携式运行/ APR,如前所述这里.我的问题是,我甚至无法构建APR,因此无法开始使用ActiveMQ-CPP.我已经按照本指南的说法,在并行目录中设置,将版本名称重命名为标准名称,并将启动项目更改为libaprutil(使用动态库),但没有任何运气.在构建APR解决方案时,27个项目中只有13个成功.我也尝试使用静态aprutil项目构建解决方案作为启动项目,但没有任何改进.

解决方案是确保为Visual Studio 6提供更广泛的兼容性,因此我怀疑使用Visual Studio 2010来解决我的问题.即使升级项目应该是可能的(如APR文档所述),在使用升级助手并尝试构建整个解决方案之后,我有几个(我认为是)缺少项目中的依赖项,请参阅第1个screendump.许多错误与文件iconv_module.obj(error LNK2019: unresolved external symbol xxx referenced in function _iconv_getpath C:\work\apr-iconv\iconv_module.obj)有关,如下面的工具提示所示C:\work\apr-iconv.该文件实际上位于不同的子文件夹中,具体取决于构建格式(我选择了"Release"和"Win32"),但我不确定这是否实际上是一个问题.

我应该提一下,我对C++完全不熟悉并且对C的经验非常有限,所以也许只是手动链接我不理解的依赖...如果打开所提到的文件并查看所述的函数然而,错误消息,代码显然也是错误的,所以也许它不是依赖关系,请看两个screendump.

关于可能的解决方案我被建议尝试手动一次构建每个项目,而不是一次完成整个解决方案,因此首先构建不依赖于任何内容的库,依此类推.然而,这也没有成功.

也应该可以使用命令行来构建项目,这对某些人来说就是技巧(链接).在新版本的Visual Studio中,"msdev"似乎被"devenv"所取代,但是考虑到这一点,构建仍然会在使用查找和替换之后抱怨"找不到msdev"......也许不是最好的解决方法,对吧?

在搜索有类似问题的帖子时,我肯定并不孤单,但不幸的是,没有一个建议的解决方案能为我做到这一点.有些我看着帖子是:编译Apache APR在WindowsActiveMQ的-CPP和Visual Studio 2003.

您是否有任何使用较新版本的Visual Studio或Windows命令行构建APR的经验?或者更重要的是,让ActiveMQ-CPP在Windows上运行?

截图:

bap*_*n93 2

我能够使用 ActiveMQ 源中的 README.txt 中的说明通过命令行构建 APR。

6.2.1 APR 库。

APR 仅以源代码形式由 Apache 软件基金会提供。您需要通过从以下位置下载最新版本来从源代码构建库:

http://apr.apache.org/
Run Code Online (Sandbox Code Playgroud)

在撰写本文时,最新版本为 v1.5.2,建议使用该版本,因为其构建支持文件可与 Visual Studio 2010 工具配合使用。

APR 是使用其提供的 Make 文件从命令行构建的。构建库时,您需要确保处于正确的环境中来生成所需的体系结构构建(x64 或 win32)。您可以使用 Visual Studio 开始菜单位置下的快捷方式打开正确的命令行(例如 Visual Studio 2010 / Visual Studio Tools / Visual Studio x64 win 64 命令提示符

进入正确的命令提示符后,更改到 APR 源代码所在的目录(例如:C:\APR),然后运行库的构建以生成所需的 ARCH 构建。

对于安装到正确的分发目录中的 32 位库,运行:

nmake -f Makefile.win ARCH="Win32 Release" PREFIX=C:\dist\APR\x64 buildall install clean
Run Code Online (Sandbox Code Playgroud)

对于 64 位版本的库,请使用该命令。

nmake -f Makefile.win ARCH="x64 Release" PREFIX=C:\dist\APR\x64 buildall install clean
Run Code Online (Sandbox Code Playgroud)


我做了:

转到:开始菜单 > 所有程序 > Visual Studio 2017 > Visual Studio Tools 并启动开发人员命令提示符。从那里导航到 APR 源的位置并运行适当的命令。在 64 位 Windows 7 上我运行nmake -f Makefile.win ARCH="Win32 Release" PREFIX=C:\dist\APR\x64 buildall install clean

更通用:

转到:开始菜单 > 所有程序 > Visual Studio 2017 > Visual Studio 工具 > VC,然后启动您正在构建的体系结构的命令提示符。nmake -f Makefile.win ARCH="x64 Release" PREFIX=C:\dist\APR\x64 buildall install clean然后使用if Building for x64 架构继续上述步骤。

这样就成功构建了APR并将其放入C:\dist\APR\x64


然后在 Visual Studio 中确保C:\dist\APR\x64\includes在项目属性的“附加包含”中链接。

  1. 右键单击您的项目并选择属性
  2. 展开配置属性
  3. 扩展C/C++
  4. 选择常规
  5. 编辑其他包含目录并添加 C:\path\to\APR\arch\include
  6. 应用更改

此时构建会产生以下错误(解决方案见下文):

1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(53): error C2039: 'auto_ptr': is not a member of 'std'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\sstream(13): note: see declaration of 'std'
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(53): error C2143: syntax error: missing ';' before '<'
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(53): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(53): error C2238: unexpected token(s) preceding ';'
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(55): error C2614: 'decaf::internal::security::SRNGData': illegal member initialization: 'random' is not a base or member
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(74): error C2039: 'random': is not a member of 'decaf::internal::security::SRNGData'
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(45): note: see declaration of 'decaf::internal::security::SRNGData'
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(74): error C2228: left of '.reset' must have class/struct/union
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(96): error C2039: 'random': is not a member of 'decaf::internal::security::SRNGData'
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(45): note: see declaration of 'decaf::internal::security::SRNGData'
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(96): error C2228: left of '.get' must have class/struct/union
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(99): error C2039: 'random': is not a member of 'decaf::internal::security::SRNGData'
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(45): note: see declaration of 'decaf::internal::security::SRNGData'
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(99): error C2227: left of '->setSeed' must point to class/struct/union/generic type
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(117): error C2039: 'random': is not a member of 'decaf::internal::security::SRNGData'
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(45): note: see declaration of 'decaf::internal::security::SRNGData'
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(117): error C2228: left of '.get' must have class/struct/union
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(140): error C2039: 'random': is not a member of 'decaf::internal::security::SRNGData'
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(45): note: see declaration of 'decaf::internal::security::SRNGData'
1>..\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp(140): error C2227: left of '->nextBytes' must point to class/struct/union/generic type
Run Code Online (Sandbox Code Playgroud)

要解决错误,请通过在文件顶部activemq-cpp-library-3.9.4\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp添加进行编辑。#include <memory>

添加上述内容后进行重建将成功构建 ActiveMQ。

输出到:activemq-cpp-library-3.9.4\vs2010-build\\Win32\Release\libactivemq-cpp.lib