Cross-compile ActiveMQ-cpp on Centos 5

To date an RPM for activemq-cpp is not available for Centos 5. I found RPMs in Fedora 13 and 14 repositories, but due to dependencies on fresher libs, they won't install.

Building for 32 bit architecture on 64 bit Centos 5 was a bit tricky. Here's the recipe I came up with that worked for me:

Install dependencies:


yum install expat-devel zlib-devel uuid-c++-devel openssl-devel


Download sources from here or other mirrors:


wget http://www.carfab.com/apachesoftware/activemq/activemq-cpp/source/activemq-cpp-library-3.2.1-src.tar.gz
wget http://mirror.candidhosting.com/pub/apache/apr/apr-1.4.2.tar.gz


Extract archives and build APR first. Note PKG_CONFIG_PATH, as this is one of the keys to ensuring that lib64 libraries are not found during link step.


[root@myserver] cd apr-1.4.2
[root@myserver] ./configure --prefix=/usr --libdir=/usr/lib CXXFLAGS="-m32" LDFLAGS="-m32" CFLAGS="-m32" --build=i686-redhat-linux-gnu PKG_CONFIG_PATH=/usr/lib/pkgconfig
[root@myserver] ./make
[root@myserver] ./make install


Next build and install ActiveMQ-cpp:


[root@myserver] cd ../activemq-cpp-library-3.2.1
[root@myserver] ./configure --prefix=/usr --libdir=/usr/lib CXXFLAGS="-m32" LDFLAGS="-m32" CFLAGS="-m32" --build=i686-redhat-linux-gnu PKG_CONFIG_PATH=/usr/lib/pkgconfig --with-apr=../apr-1.4.2/apr-1-config
[root@myserver] ./make
[root@myserver] ./make install

Comments

devinvenable said…
Upon running a program that uses active-mq-library-3.2.1 built using the steps above, I got a core dump. There are fixes in the 3.2.x fixes branch, but that branch requires a newer version of autoconf than is available from repo for Centos 5. You can apply this patch to fix the issue:

Index: src/main/decaf/net/InetAddress.h
===================================================================
--- src/main/decaf/net/InetAddress.h (revision 958115)
+++ src/main/decaf/net/InetAddress.h (revision 964945)
@@ -36,9 +36,6 @@
static const unsigned char loopbackBytes[4];
static const unsigned char anyBytes[4];

- static const InetAddress ANY;
- static const InetAddress LOOPBACK;
-
protected:

mutable std::string hostname;
@@ -234,6 +231,10 @@
*/
static unsigned int bytesToInt( const unsigned char* bytes, int start );

+ static InetAddress getAnyAddress();
+
+ static InetAddress getLoopbackAddress();
+
};

}}
Index: src/main/decaf/net/InetAddress.cpp
===================================================================
--- src/main/decaf/net/InetAddress.cpp (revision 958115)
+++ src/main/decaf/net/InetAddress.cpp (revision 964945)
@@ -36,9 +36,6 @@
const unsigned char InetAddress::loopbackBytes[4] = { 127, 0, 0, 1 };
const unsigned char InetAddress::anyBytes[4] = { 0, 0, 0, 0 };

-const InetAddress InetAddress::LOOPBACK( Inet4Address( "localhost", InetAddress::loopbackBytes, 4 ) );
-const InetAddress InetAddress::ANY( Inet4Address( InetAddress::anyBytes, 4 ) );
-
////////////////////////////////////////////////////////////////////////////////
InetAddress::InetAddress() {
}
@@ -154,7 +151,7 @@
apr_status_t result = apr_gethostname( hostname, APRMAXHOSTLEN+1, pool.getAprPool() );

if( result != APR_SUCCESS ) {
- return InetAddress::LOOPBACK;
+ return getLoopbackAddress();
}

apr_sockaddr_t* address = NULL;
@@ -188,3 +185,13 @@

return value;
}
+
+////////////////////////////////////////////////////////////////////////////////
+InetAddress InetAddress::getAnyAddress() {
+ return Inet4Address( "localhost", InetAddress::loopbackBytes, 4 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+InetAddress InetAddress::getLoopbackAddress() {
+ return Inet4Address( InetAddress::anyBytes, 4 );
+}
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Anonymous said…
This comment has been removed by a blog administrator.
Joe said…
Hi Devin,

for x-compiling activemq on centos, May I ask how do you get the uuid-c++-devel package? It's not available anywhere on yum.

Thank you!!

Joe

Popular Posts