ActiveMQ-CPP在linux环境下的编译

        (1) 编译安装cppunit-1.12.1 ,切换至该目录。执行./configure --prefix=/usr/local/cppunit/ ,执行make,再执行make install 进行安装。这时可以到/usr/local下查看会生成cppunit目录。

        在linux能正常编译,但在solaris下make时遇到点问题,报错:

        ../../include/cppunit/portability/FloatingPoint.h:43: error: `finite' undeclared (first use this function)
        解决办法:找到include/cppunit/portability/FloatingPoint.h,在前面加入#include <ieeefp.h> 即可

 

        (2) 编译安装apr-1.4.2 ,切换至该目录。执行./configure --prefix=/usr/local/apr/ ,执行make,再执行make install 进行安装。这时可以到/usr/local下查看会生成apr目录。

   (3)编译安装apr-util-1.3.9,切换至该目录。执行./configure --prefix=/usr/local/aprutil --with-apr=/usr/local/apr/,执行make,执行make install。这时可以到/usr/local下查看会生成apache目录。

 

        (4)编译安装apr-iconv-1.2.1 ,切换至该目录。执行./configure --prefix=/usr/local/apr-iconv/  --with-apr=/usr/local/apr/,执行make,再执行make install 进行安装。这时可以到/usr/local下查看会生成apr-conv目录。

 

        (5)编译安装openssl 1.0.0a ,切换至该目录。执行./config --prefix=/usr/local/openssl/,执行sudo make,再执行sudo make install 进行安装。这时可以到/usr/local下查看会生成openssl目录。

 

        (6)编译安装e2fsprogs,切换至该目录。执行./configure --prefix=/usr --with-root-prefix="" --enable-elf-shlibs,执行sudo make,再执行sudo make install 进行安装。

        下载地址:http://e2fsprogs.sourceforge.net/

        参考:http://man.chinaunix.net/linux/lfs/htmlbook/chapter06/e2fsprogs.html

 

        (7)编译安装expat, 切换至该目录。执行./configure --prefix=/usr,执行sudo make,再执行sudo make install 进行安装.

        expat下载地址:http://prdownloads.sourceforge.net/expat/expat-1.95.7.tar.gz

 

        (8)编译安装ActiveMQ-CPP ,切换至该目录。执行./configure --prefix=/usr/local/ActiveMQ-CPP --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/aprutil --with-cppunit=/usr/local/cppunit --with-openssl=/usr/local/openssl,执行make,在执行make install 进行安装。这时可以到/usr/local下查看会生成AtiveMQ-CPP目录。

 

我下的是ActiveMQ-CPP 3.2.1,源代码有些问题,造成编译生成的example程序运行报错,见下面的GDB调试信息:

chenbo@ubuntu:/usr/local/ActiveMQ-CPP/bin$ gdb example
GNU gdb (GDB) 7.1-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/local/ActiveMQ-CPP/bin/example...done.
(gdb) r
Starting program: /usr/local/ActiveMQ-CPP/bin/example
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
0x009b2ff7 in mutex_hash (mem=0x804f09c, val=4294967295)
    at atomic/unix/mutex.c:78
78        apr_thread_mutex_t *mutex = hash_mutex[ATOMIC_HASH(mem)];
(gdb) bt
#0  0x009b2ff7 in mutex_hash (mem=0x804f09c, val=4294967295)
    at atomic/unix/mutex.c:78
#1  apr_atomic_add32 (mem=0x804f09c, val=4294967295) at atomic/unix/mutex.c:113
#2  0x0079e4c8 in decaf::util::concurrent::atomic::AtomicInteger::decrementAndGet (this=0x804f098) at decaf/util/concurrent/atomic/AtomicInteger.cpp:69
#3  0x007600bc in decaf::util::concurrent::atomic::AtomicRefCounter::release (
    this=0xbffff24c, hostname=..., ipAddress=0x7dc95f "/177", numBytes=4)
    at ./decaf/util/concurrent/atomic/AtomicRefCounter.h:68
#4  ~ArrayPointer (this=0xbffff24c, hostname=..., ipAddress=0x7dc95f "/177",
    numBytes=4) at ./decaf/lang/ArrayPointer.h:154
#5  decaf::lang::ArrayPointer<unsigned char, decaf::util::concurrent::atomic::AtomicRefCounter>::reset (this=0xbffff24c, hostname=...,
    ipAddress=0x7dc95f "/177", numBytes=4) at ./decaf/lang/ArrayPointer.h:171
#6  InetAddress (this=0xbffff24c, hostname=..., ipAddress=0x7dc95f "/177",
    numBytes=4) at decaf/net/InetAddress.cpp:79
#7  0x0075d647 in Inet4Address (this=0xbffff24c, hostname=...,
    ipAddress=0x7dc95f "/177", numBytes=4) at decaf/net/Inet4Address.cpp:34
#8  0x0075e44b in __static_initialization_and_destruction_0 ()
    at decaf/net/InetAddress.cpp:39
#9  global constructors keyed to InetAddress.cpp ()
    at decaf/net/InetAddress.cpp:190
#10 0x007b38bd in __do_global_ctors_aux ()
   from /usr/local/ActiveMQ-CPP/lib/libactivemq-cpp.so.11
---Type <return> to continue, or q <return> to quit---
#11 0x0034fc94 in _init ()
   from /usr/local/ActiveMQ-CPP/lib/libactivemq-cpp.so.11
#12 0x0011dc4c in call_init (l=<value optimized out>,
    argc=<value optimized out>, argv=0xbffff354, env=0xbffff35c)
    at dl-init.c:70
#13 0x0011dd69 in _dl_init (main_map=0x12c8f8, argc=<value optimized out>,
    argv=<value optimized out>, env=0xbffff35c) at dl-init.c:134
#14 0x0011088f in _dl_start_user () from /lib/ld-linux.so.2
(gdb)

 

google了一下,有人遇到同样的问题:

http://old.nabble.com/-jira--Created%3A-(AMQCPP-303)-SEGFAULT-on-startup-(before-main)-td29184816.html

 

并且ActiveMQ很快更新了相关代码:

https://issues.apache.org/activemq/browse/AMQCPP-303?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

 

根据其中的链接找到InetAddress.h和InetAddress.cpp,更新本地的相应文件即可。

 

然后重新编译ActiveMQ-CPP,生成新的库文件及example,运行example,ActiveMQ通信成功!

你可能感兴趣的:(thread,linux,activemq,Solaris,initialization,debugging)