ubuntu下安装rabbitmq-c-master

概述:

目的是在ubuntu 12.04.04桌面版上运行rabbitmq-c的客户端程序。

操作步骤:

1、下载源码:RabbitMQ的-C

RabbitMQ的Ç客户端已经搬迁到了链接地址https://github.com/alanxz/rabbitmq-c

leekwen@leekwen:~$ git clone https://github.com/alanxz/rabbitmq-c
	Initialized empty Git repository in /home/leekwen/rabbitmq-c/.git/
	remote: Counting objects: 4336, done.
	remote: Compressing objects: 100% (1778/1778), done.
	remote: Total 4336 (delta 2521), reused 4328 (delta 2515)
	Receiving objects: 100% (4336/4336), 2.25 MiB | 85 KiB/s, done.
	Resolving deltas: 100% (2521/2521), done.

2、这里我就直接进入编译主题了 (建议大家最好还是先要看下README.md)

leekwen@leekwen:~$ cd rabbitmq-c; mkdir build; cd build
leekwen@leekwen:~/rabbitmq-c/build$ cmake ..  //编译即可

编译中可能出现的问题:

问题1、没有安装cmake工具

运行如下命令:

leekwen@leekwen:~/rabbitmq-c/build$ sudo apt-get install cmake

问题2、没有编译环境所依赖的工具

会出现如下的error信息:

leekwen@leekwen:~/rabbitmq-c/build$ cmake ..
-- The C compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- CMAKE_BUILD_TYPE not specified. Creating Release build
-- Found C inline keyword: inline
-- Looking for getaddrinfo
-- Looking for getaddrinfo - found
-- Looking for socket
-- Looking for socket - found
-- Looking for htonll
-- Looking for htonll - not found
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - found
-- Could NOT find POPT (missing:  POPT_INCLUDE_DIR POPT_LIBRARY)
-- Found XMLTO: /usr/bin/xmlto
-- Found Doxygen: /usr/bin/doxygen
-- Looking for include files CMAKE_HAVE_PTHREAD_H
-- Looking for include files CMAKE_HAVE_PTHREAD_H - found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:91 (MESSAGE):
  Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
  system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES
  OPENSSL_INCLUDE_DIR) (Required is at least version "0.9.8")
Call Stack (most recent call first):
  /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:252 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-2.8/Modules/FindOpenSSL.cmake:244 (find_package_handle_standard_args)
  CMakeLists.txt:240 (find_package)


-- Configuring incomplete, errors occurred!

运行如下命令解决:

leekwen@leekwen:~/rabbitmq-c/build$ sudo apt-get install -y xmlto doxygen

其它:

假如再次出现有关没有安装OPENSSL_LIBRARIES库的问题,错误如下:

leekwen@leekwen:~/rabbitmq-c/build$ cmake ..
-- Could NOT find POPT (missing:  POPT_INCLUDE_DIR POPT_LIBRARY)
-- Found XMLTO: /usr/bin/xmlto
-- Found Doxygen: /usr/bin/doxygen
-- checking for module 'openssl'
--   package 'openssl' not found
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:91 (MESSAGE):
  Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
  system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES
  OPENSSL_INCLUDE_DIR) (Required is at least version "0.9.8")
Call Stack (most recent call first):
  /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:252 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-2.8/Modules/FindOpenSSL.cmake:244 (find_package_handle_standard_args)
  CMakeLists.txt:240 (find_package)


-- Configuring incomplete, errors occurred!

运行 如下的命令即可:

leekwen@leekwen:~/rabbitmq-c/build$ sudo apt-get install -y openssl-devel
或
leekwen@leekwen:~/rabbitmq-c/build$ sudo apt-get install -y openssl libssl-dev

正确的编译过程如下:

leekwen@leekwen:~/rabbitmq-c/build$ cmake ..
-- Could NOT find POPT (missing:  POPT_INCLUDE_DIR POPT_LIBRARY)
-- checking for module 'openssl'
--   found openssl, version 1.0.1
-- Found OpenSSL: /usr/lib/i386-linux-gnu/libssl.so;/usr/lib/i386-linux-gnu/libcrypto.so (found suitable version "1..1", required is "0.9.8")
-- Building rabbitmq as a shared library - yes
-- Building rabbitmq as a static library - no
-- Configuring done
-- Generating done
-- Build files have been written to: /home/leekwen/rabbitmq-c/build

leekwen@leekwen:~/rabbitmq-c/build$ make
Scanning dependencies of target rabbitmq
[  1%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_framing.c.o
[  2%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_api.c.o
[  4%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_connection.c.o
[  5%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_mem.c.o
[  7%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_socket.c.o
[  8%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_table.c.o
[ 10%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_url.c.o
[ 11%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_tcp_socket.c.o
[ 12%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_timer.c.o
[ 14%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_consumer.c.o
[ 15%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_openssl.c.o
Linking C shared library librabbitmq.so
[ 15%] Built target rabbitmq
Scanning dependencies of target amqp_bind
[ 17%] Building C object examples/CMakeFiles/amqp_bind.dir/amqp_bind.c.o
[ 18%] Building C object examples/CMakeFiles/amqp_bind.dir/utils.c.o
[ 20%] Building C object examples/CMakeFiles/amqp_bind.dir/unix/platform_utils.c.o
Linking C executable amqp_bind
[ 20%] Built target amqp_bind
Scanning dependencies of target amqp_connect_timeout
[ 21%] Building C object examples/CMakeFiles/amqp_connect_timeout.dir/amqp_connect_timeout.c.o
[ 22%] Building C object examples/CMakeFiles/amqp_connect_timeout.dir/utils.c.o
[ 24%] Building C object examples/CMakeFiles/amqp_connect_timeout.dir/unix/platform_utils.c.o
Linking C executable amqp_connect_timeout
[ 24%] Built target amqp_connect_timeout
Scanning dependencies of target amqp_consumer
[ 25%] Building C object examples/CMakeFiles/amqp_consumer.dir/amqp_consumer.c.o
[ 27%] Building C object examples/CMakeFiles/amqp_consumer.dir/utils.c.o
[ 28%] Building C object examples/CMakeFiles/amqp_consumer.dir/unix/platform_utils.c.o
Linking C executable amqp_consumer
[ 28%] Built target amqp_consumer
Scanning dependencies of target amqp_exchange_declare
[ 30%] Building C object examples/CMakeFiles/amqp_exchange_declare.dir/amqp_exchange_declare.c.o
[ 31%] Building C object examples/CMakeFiles/amqp_exchange_declare.dir/utils.c.o
[ 32%] Building C object examples/CMakeFiles/amqp_exchange_declare.dir/unix/platform_utils.c.o
Linking C executable amqp_exchange_declare
[ 32%] Built target amqp_exchange_declare
Scanning dependencies of target amqp_listen
[ 34%] Building C object examples/CMakeFiles/amqp_listen.dir/amqp_listen.c.o
[ 35%] Building C object examples/CMakeFiles/amqp_listen.dir/utils.c.o
[ 37%] Building C object examples/CMakeFiles/amqp_listen.dir/unix/platform_utils.c.o
Linking C executable amqp_listen
[ 37%] Built target amqp_listen
Scanning dependencies of target amqp_listenq
[ 38%] Building C object examples/CMakeFiles/amqp_listenq.dir/amqp_listenq.c.o
[ 40%] Building C object examples/CMakeFiles/amqp_listenq.dir/utils.c.o
[ 41%] Building C object examples/CMakeFiles/amqp_listenq.dir/unix/platform_utils.c.o
Linking C executable amqp_listenq
[ 41%] Built target amqp_listenq
Scanning dependencies of target amqp_producer
[ 42%] Building C object examples/CMakeFiles/amqp_producer.dir/amqp_producer.c.o
[ 44%] Building C object examples/CMakeFiles/amqp_producer.dir/utils.c.o
[ 45%] Building C object examples/CMakeFiles/amqp_producer.dir/unix/platform_utils.c.o
Linking C executable amqp_producer
[ 45%] Built target amqp_producer
Scanning dependencies of target amqp_rpc_sendstring_client
[ 47%] Building C object examples/CMakeFiles/amqp_rpc_sendstring_client.dir/amqp_rpc_sendstring_client.c.o
[ 48%] Building C object examples/CMakeFiles/amqp_rpc_sendstring_client.dir/utils.c.o
[ 50%] Building C object examples/CMakeFiles/amqp_rpc_sendstring_client.dir/unix/platform_utils.c.o
Linking C executable amqp_rpc_sendstring_client
[ 50%] Built target amqp_rpc_sendstring_client
Scanning dependencies of target amqp_sendstring
[ 51%] Building C object examples/CMakeFiles/amqp_sendstring.dir/amqp_sendstring.c.o
[ 52%] Building C object examples/CMakeFiles/amqp_sendstring.dir/utils.c.o
[ 54%] Building C object examples/CMakeFiles/amqp_sendstring.dir/unix/platform_utils.c.o
Linking C executable amqp_sendstring
[ 54%] Built target amqp_sendstring
Scanning dependencies of target amqp_unbind
[ 55%] Building C object examples/CMakeFiles/amqp_unbind.dir/amqp_unbind.c.o
[ 57%] Building C object examples/CMakeFiles/amqp_unbind.dir/utils.c.o
[ 58%] Building C object examples/CMakeFiles/amqp_unbind.dir/unix/platform_utils.c.o
Linking C executable amqp_unbind
[ 58%] Built target amqp_unbind
Scanning dependencies of target amqps_bind
[ 60%] Building C object examples/CMakeFiles/amqps_bind.dir/amqps_bind.c.o
[ 61%] Building C object examples/CMakeFiles/amqps_bind.dir/utils.c.o
[ 62%] Building C object examples/CMakeFiles/amqps_bind.dir/unix/platform_utils.c.o
Linking C executable amqps_bind
[ 62%] Built target amqps_bind
Scanning dependencies of target amqps_connect_timeout
[ 64%] Building C object examples/CMakeFiles/amqps_connect_timeout.dir/amqps_connect_timeout.c.o
[ 65%] Building C object examples/CMakeFiles/amqps_connect_timeout.dir/utils.c.o
[ 67%] Building C object examples/CMakeFiles/amqps_connect_timeout.dir/unix/platform_utils.c.o
Linking C executable amqps_connect_timeout
[ 67%] Built target amqps_connect_timeout
Scanning dependencies of target amqps_consumer
[ 68%] Building C object examples/CMakeFiles/amqps_consumer.dir/amqps_consumer.c.o
[ 70%] Building C object examples/CMakeFiles/amqps_consumer.dir/utils.c.o
[ 71%] Building C object examples/CMakeFiles/amqps_consumer.dir/unix/platform_utils.c.o
Linking C executable amqps_consumer
[ 71%] Built target amqps_consumer
Scanning dependencies of target amqps_exchange_declare
[ 72%] Building C object examples/CMakeFiles/amqps_exchange_declare.dir/amqps_exchange_declare.c.o
[ 74%] Building C object examples/CMakeFiles/amqps_exchange_declare.dir/utils.c.o
[ 75%] Building C object examples/CMakeFiles/amqps_exchange_declare.dir/unix/platform_utils.c.o
Linking C executable amqps_exchange_declare
[ 75%] Built target amqps_exchange_declare
Scanning dependencies of target amqps_listen
[ 77%] Building C object examples/CMakeFiles/amqps_listen.dir/amqps_listen.c.o
[ 78%] Building C object examples/CMakeFiles/amqps_listen.dir/utils.c.o
[ 80%] Building C object examples/CMakeFiles/amqps_listen.dir/unix/platform_utils.c.o
Linking C executable amqps_listen
[ 80%] Built target amqps_listen
Scanning dependencies of target amqps_listenq
[ 81%] Building C object examples/CMakeFiles/amqps_listenq.dir/amqps_listenq.c.o
[ 82%] Building C object examples/CMakeFiles/amqps_listenq.dir/utils.c.o
[ 84%] Building C object examples/CMakeFiles/amqps_listenq.dir/unix/platform_utils.c.o
Linking C executable amqps_listenq
[ 84%] Built target amqps_listenq
Scanning dependencies of target amqps_producer
[ 85%] Building C object examples/CMakeFiles/amqps_producer.dir/amqps_producer.c.o
[ 87%] Building C object examples/CMakeFiles/amqps_producer.dir/utils.c.o
[ 88%] Building C object examples/CMakeFiles/amqps_producer.dir/unix/platform_utils.c.o
Linking C executable amqps_producer
[ 88%] Built target amqps_producer
Scanning dependencies of target amqps_sendstring
[ 90%] Building C object examples/CMakeFiles/amqps_sendstring.dir/amqps_sendstring.c.o
[ 91%] Building C object examples/CMakeFiles/amqps_sendstring.dir/utils.c.o
[ 92%] Building C object examples/CMakeFiles/amqps_sendstring.dir/unix/platform_utils.c.o
Linking C executable amqps_sendstring
[ 92%] Built target amqps_sendstring
Scanning dependencies of target amqps_unbind
[ 94%] Building C object examples/CMakeFiles/amqps_unbind.dir/amqps_unbind.c.o
[ 95%] Building C object examples/CMakeFiles/amqps_unbind.dir/utils.c.o
[ 97%] Building C object examples/CMakeFiles/amqps_unbind.dir/unix/platform_utils.c.o
Linking C executable amqps_unbind
[ 97%] Built target amqps_unbind
Scanning dependencies of target test_parse_url
[ 98%] Building C object tests/CMakeFiles/test_parse_url.dir/test_parse_url.c.o
Linking C executable test_parse_url
[ 98%] Built target test_parse_url
Scanning dependencies of target test_tables
[100%] Building C object tests/CMakeFiles/test_tables.dir/test_tables.c.o
/home/leekwen/rabbitmq-c/tests/test_tables.c: In function ‘dump_value’:
/home/leekwen/rabbitmq-c/tests/test_tables.c:108:5: warning: ISO C90 does not support the ‘ll’ gnu_printf length modifier [-Wformat]
/home/leekwen/rabbitmq-c/tests/test_tables.c:147:5: warning: ISO C90 does not support the ‘ll’ gnu_printf length modifier [-Wformat]
/home/leekwen/rabbitmq-c/tests/test_tables.c: In function ‘test_dump_value’:
/home/leekwen/rabbitmq-c/tests/test_tables.c:201:3: warning: integer constant is too large for ‘long’ type [-Wlong-long]
/home/leekwen/rabbitmq-c/tests/test_tables.c: In function ‘test_table_codec’:
/home/leekwen/rabbitmq-c/tests/test_tables.c:307:3: warning: integer constant is too large for ‘long’ type [-Wlong-long]
Linking C executable test_tables
[100%] Built target test_tables



到此编译的环境已经完成了,Enjoy It...~

Leekwen CSDN认证博客专家 安全架构 物联网 研发者
个人微信:leekwenty
具体的信息,大家可自行去百度搜索关键词:leekwen
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页
实付 99.90元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值