admin管理员组

文章数量:1125322

I am attempting to use activemq-cpp within my Go application.

I have cloned the activemq-cpp repo and followed all the instructions to install it on my machine.

I have created a .cpp wrapper that allows me to import it using Go which I can call successfully.

Here is the wrapper

#include <activemq/core/ActiveMQConnectionFactory.h>
#include <activemq/library/ActiveMQCPP.h>
#include <cms/Connection.h>
#include <cms/Session.h>
#include <cms/Destination.h>
#include <cms/MessageProducer.h>
#include <cms/TextMessage.h>
#include <decaf/lang/System.h>
#include <iostream>
#include <memory>
#include <string>

extern "C" {

// Initialize ActiveMQ library
void ActiveMQCPPInitializeLibrary() {
    activemq::library::ActiveMQCPP::initializeLibrary();
}

// Shutdown ActiveMQ library
void ActiveMQCPPShutdownLibrary() {
    activemq::library::ActiveMQCPP::shutdownLibrary();
}

// Create a connection to ActiveMQ
void* CreateConnection(const char* brokerURI) {
    try {
        decaf::lang::System::setProperty( "decaf.ssl.disablePeerVerification", "true" );

        auto factory = std::make_unique<activemq::core::ActiveMQConnectionFactory>(brokerURI);

        cms::Connection* connection = factory->createConnection();

        return (void*)connection;
    } catch (const cms::CMSException& e) {
        std::cerr << "CMSException: " << e.getMessage() << std::endl;
        return nullptr;
    }
}

Which I build with

g++ -I. -shared -o libactivemq_wrapper.so -fPIC activemq_wrapper.cpp

I have the .h files in the root directory alongside my .cpp wrapper, I have the headers for activemq, cms and decaf.

The issue I'm having is when I try and add this line

decaf::lang::System::setProperty( "decaf.ssl.disablePeerVerification", "true" );

With the import #include <decaf/lang/System.h>

This then leads to the compiler erroring with

/decaf/internal/AprPool.h:39:17: error: ‘apr_pool_t’ does not name a type; did you mean ‘AprPool’?
   39 |         mutable apr_pool_t* aprPool;
      |                 ^~~~~~~~~~
      |                 AprPool
./decaf/internal/AprPool.h:55:9: error: ‘apr_pool_t’ does not name a type; did you mean ‘AprPool’?
   55 |         apr_pool_t* getAprPool() const;
      |         ^~~~~~~~~~
      |         AprPool
./decaf/internal/AprPool.h:68:16: error: ‘apr_pool_t’ does not name a type; did you mean ‘AprPool’?
   68 |         static apr_pool_t* getGlobalPool();
      |                ^~~~~~~~~~
      |                AprPool

I have installed APR locally with sudo apt-get install apache2-dev libapr1-dev libaprutil1-dev but I'm getting the same compiler issue. I'm a bit lost with this as I'm quite new to C++

I am attempting to use activemq-cpp within my Go application.

I have cloned the activemq-cpp repo https://github.com/apache/activemq-cpp and followed all the instructions to install it on my machine.

I have created a .cpp wrapper that allows me to import it using Go which I can call successfully.

Here is the wrapper

#include <activemq/core/ActiveMQConnectionFactory.h>
#include <activemq/library/ActiveMQCPP.h>
#include <cms/Connection.h>
#include <cms/Session.h>
#include <cms/Destination.h>
#include <cms/MessageProducer.h>
#include <cms/TextMessage.h>
#include <decaf/lang/System.h>
#include <iostream>
#include <memory>
#include <string>

extern "C" {

// Initialize ActiveMQ library
void ActiveMQCPPInitializeLibrary() {
    activemq::library::ActiveMQCPP::initializeLibrary();
}

// Shutdown ActiveMQ library
void ActiveMQCPPShutdownLibrary() {
    activemq::library::ActiveMQCPP::shutdownLibrary();
}

// Create a connection to ActiveMQ
void* CreateConnection(const char* brokerURI) {
    try {
        decaf::lang::System::setProperty( "decaf.net.ssl.disablePeerVerification", "true" );

        auto factory = std::make_unique<activemq::core::ActiveMQConnectionFactory>(brokerURI);

        cms::Connection* connection = factory->createConnection();

        return (void*)connection;
    } catch (const cms::CMSException& e) {
        std::cerr << "CMSException: " << e.getMessage() << std::endl;
        return nullptr;
    }
}

Which I build with

g++ -I. -shared -o libactivemq_wrapper.so -fPIC activemq_wrapper.cpp

I have the .h files in the root directory alongside my .cpp wrapper, I have the headers for activemq, cms and decaf.

The issue I'm having is when I try and add this line

decaf::lang::System::setProperty( "decaf.net.ssl.disablePeerVerification", "true" );

With the import #include <decaf/lang/System.h>

This then leads to the compiler erroring with

/decaf/internal/AprPool.h:39:17: error: ‘apr_pool_t’ does not name a type; did you mean ‘AprPool’?
   39 |         mutable apr_pool_t* aprPool;
      |                 ^~~~~~~~~~
      |                 AprPool
./decaf/internal/AprPool.h:55:9: error: ‘apr_pool_t’ does not name a type; did you mean ‘AprPool’?
   55 |         apr_pool_t* getAprPool() const;
      |         ^~~~~~~~~~
      |         AprPool
./decaf/internal/AprPool.h:68:16: error: ‘apr_pool_t’ does not name a type; did you mean ‘AprPool’?
   68 |         static apr_pool_t* getGlobalPool();
      |                ^~~~~~~~~~
      |                AprPool

I have installed APR locally with sudo apt-get install apache2-dev libapr1-dev libaprutil1-dev but I'm getting the same compiler issue. I'm a bit lost with this as I'm quite new to C++

Share Improve this question edited 2 days ago Eric Postpischil 221k13 gold badges183 silver badges354 bronze badges asked 2 days ago pococknpocockn 2,0635 gold badges23 silver badges41 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

To fix this I ran the below on the terminal

find /usr/include -name apr_pools.h

Which returned /usr/include/apr-1.0/apr_pools.h

To get the location where APR is installed and then added it as a include to the g++ command via the -I flag

g++ -I/usr/include/apr-1.0 -I. -shared -o libactivemq_wrapper.so -fPIC activemq_wrapper.cpp

本文标签: cerror aprpoolt’ does not name a type did you mean AprPool’Stack Overflow