c++visual-studioactivemq-classicapractivemq-cpp

How to build Apache ActiveMQ-CPP (and APR) on Windows?


I'm trying get some functionality written in C++ to communicate with Apache ActiveMQ (which natively uses JMS) located on a Linux machine. To make this connection I have tried to set up Apache ActiveMQ-CPP on my Windows 7 machine (development machine), but I am currently facing some major problems.

As far as I understand ActiveMQ-CPP has a dependency to Apache Portable Runtime/APR, as stated here. My problem is, that I cannot even build APR and hence not getting started with ActiveMQ-CPP. I have followed this guide to the letter, setting up in parallel directories, renaming version names to standard names and changing startup project to libaprutil (using dynamic libraries), but without any luck. When building the APR solution only 13 of the 27 projects succeeds. I have also tried building the solution with the static aprutil project as startup project, but without any improvement.

The solution is to ensure wider compatibility made for Visual Studio 6, so I suspect the use of Visual Studio 2010 for being responsible for my problems. Even though upgrading the project should be possible (as stated by the APR documentation), I have several (what I think is) missing dependencies in the project after using the upgrade assistant and trying to build the whole solution afterwards, see 1st screendump. Many of the errors relates to a file iconv_module.obj (error LNK2019: unresolved external symbol xxx referenced in function _iconv_getpath C:\work\apr-iconv\iconv_module.obj), which as seen by the lower tooltip should be found in C:\work\apr-iconv. The file is actually located in different subfolders instead, depending on the build format (I have chosen "Release" and "Win32"), but I'm not sure whether this is actually a problem or not.

I should mention, that I'm totally new to C++ and only have very limited experience with C, so maybe it's just the dependencies I do not understand to link manually... if one open the mentioned file and look at the functions stated in the error messages, however, something is clearly also wrong with the code, so maybe it's not dependencies, see both screendumps.

Regarding possible solutions I have been suggested to try building each project at a time manually, rather than the whole solution at once, so libraries not dependant of anything is build first and so on. This has, however, not been successful either.

It should also be possible to use the command line to build the project, which for some people did the trick (link). "msdev" seems to be replaced by "devenv" in newer versions of Visual Studio, but eventhough with this in mind the build still complains over "msdev not found" after using find and replace... maybe not the best fix, huh?

When searching for posts with similar problems I'm surely not alone, but unfortunately none of the suggested solutions did the trick for me. Some of the posts I looked at was: Compile Apache APR on Windows and ActiveMQ-CPP and Visual Studio 2003.

Does any of you have any experience with building APR with newer versions of Visual Studio or the command line on Windows? Or more importantly, getting ActiveMQ-CPP to work on Windows?

Screenshots:


Solution

  • I was able to build APR via the command line using the instructions in README.txt in the ActiveMQ source.

    6.2.1 APR library.

    APR is provided in source form only from the Apache Software Foundation. You will need to build a library from source by downloading the latest release from:

    http://apr.apache.org/
    

    At the time of this writing the latest version was v1.5.2 and is recommended since its build support files are working with the Visual Studio 2010 tools.

    APR is built from the command line using its provided Make files. When building the library you need to ensure you are in the right environment to produce the desired architecture builds (x64 or win32). You can open a command line that's correct by using the shortcuts under the Visual Studio start menu location (ex. Visual Studio 2010 / Visual Studio Tools / Visual Studio x64 win 64 Command Prompt

    Once you are in the proper command prompt change to the directory where your APR source code is located (ex: C:\APR) and then run the build for the library to produce the desired ARCH build.

    For a 32 bit library which installs into a proper distribution directory run:

    nmake -f Makefile.win ARCH="Win32 Release" PREFIX=C:\dist\APR\x64 buildall install clean
    

    and for a 64 bit build of the library use the command.

    nmake -f Makefile.win ARCH="x64 Release" PREFIX=C:\dist\APR\x64 buildall install clean
    


    I did:

    Go to: Start Menu > All Programs > Visual Studio 2017 > Visual Studio Tools and launch the Developer Command Prompt. Navigate from there to the location of your APR source and run the appropriate command. On 64bit Windows 7 I ran nmake -f Makefile.win ARCH="Win32 Release" PREFIX=C:\dist\APR\x64 buildall install clean

    More generic:

    Go to: Start Menu > All Programs > Visual Studio 2017 > Visual Studio Tools > VC and launch the command prompt of the architecture you are building for. Then continue the above steps using nmake -f Makefile.win ARCH="x64 Release" PREFIX=C:\dist\APR\x64 buildall install clean if building for x64 architecture.

    This successfully built APR and put it in C:\dist\APR\x64


    Then in Visual Studio make sure C:\dist\APR\x64\includes is linked in the Additional Includes in the project properties.

    1. Right click your project and select Properties
    2. Expand Configuration Properties
    3. Expand C/C++
    4. Select General
    5. Edit Additional Include Directories and add C:\path\to\APR\arch\include
    6. 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