我能够使用 ActiveMQ 源中的 README.txt 中的说明通过命令行构建 APR。
6.2.1 APR 库。
APR 仅由 Apache Software Foundation 以源代码形式提供。您需要通过从以下位置下载最新版本来从源代码构建一个库:
http://apr.apache.org/
在撰写本文时,最新版本是 v1.5.2,推荐使用它,因为它的构建支持文件可与 Visual Studio 2010 工具配合使用。
APR 是使用其提供的 Make 文件从命令行构建的。在构建库时,您需要确保您处于正确的环境中以生成所需的架构构建(x64 或 win32)。您可以使用 Visual Studio 开始菜单位置下的快捷方式打开正确的命令行(例如 Visual Studio 2010 / Visual Studio Tools / Visual Studio x64 win 64 Command Prompt
在正确的命令提示符下切换到 APR 源代码所在的目录(例如:C:\APR),然后运行库的构建以生成所需的 ARCH 构建。
对于安装到正确分发目录的 32 位库,请运行:
nmake -f Makefile.win ARCH="Win32 Release" PREFIX=C:\dist\APR\x64 buildall install clean
对于库的 64 位构建,请使用该命令。
nmake -f Makefile.win ARCH="x64 Release" PREFIX=C:\dist\APR\x64 buildall install clean
我做了:
转到:开始菜单 > 所有程序 > Visual Studio 2017 > Visual Studio Tools
并启动Developer Command Prompt。从那里导航到 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 build for x64 架构继续上述步骤。
这成功构建了 APR 并放入C:\dist\APR\x64
然后在 Visual Studio 中确保C:\dist\APR\x64\includes
在项目属性的 Additional Includes 中链接。
- 右键单击您的项目并选择属性
- 展开配置属性
- 展开 C/C++
- 选择常规
- Edit Additional Include Directories and add C:\path\to\APR\arch\include
- Apply changes
Building at this point yields the following errors (See below for solution):
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
To resolve the errors edit activemq-cpp-library-3.9.4\src\main\decaf\internal\security\windows\SecureRandomImpl.cpp
by adding #include <memory>
at the top of the file.
Rebuilding after adding the above include results in a successful build of ActiveMQ.
Output to: activemq-cpp-library-3.9.4\vs2010-build\\Win32\Release\libactivemq-cpp.lib