Installing AMQP through PECL

末鹿安然 提交于 2019-12-03 09:36:23

问题


I'm trying to install the RabbitMQ PECL extension but after running

sudo pecl install amqp

I get the following cryptic error message, which extensive googling hasn't helped resolve.

I have these packages installed:

  • librabbitmq - RabbitMQ C client itself)
  • librabbitmq-dev - dev headers etc.

and RabbitMQ running successfully on localhost

Maybe it could be a mismatch in the version of the C client and what the PECL extension expects, anybody else come across this one?

Make output below....

Cheers

running: make
/bin/bash /tmp/pear/temp/pear-build-rootZNUmac/amqp-1.0.0/libtool --mode=compile cc  -I.         -I/tmp/pear/temp/amqp -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootZNUmac/amqp-        1.0.0/include -I/tmp/pear/temp/pear-build-rootZNUmac/amqp-1.0.0/main -I/tmp/pear/temp/amqp -      I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -       I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -    D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/amqp/amqp.c -o amqp.lo
libtool: compile:  cc -I. -I/tmp/pear/temp/amqp -DPHP_ATOM_INC -I/tmp/pear/temp/pear-   build-rootZNUmac/amqp-1.0.0/include -I/tmp/pear/temp/pear-build-rootZNUmac/amqp-1.0.0/main -   I/tmp/pear/temp/amqp -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -  I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -  D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -g -O2 -c    /tmp/pear/temp/amqp/amqp.c  -fPIC -DPIC -o .libs/amqp.o
/bin/bash /tmp/pear/temp/pear-build-rootZNUmac/amqp-1.0.0/libtool --mode=compile cc  -I.    -I/tmp/pear/temp/amqp -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootZNUmac/amqp-  1.0.0/include -I/tmp/pear/temp/pear-build-rootZNUmac/amqp-1.0.0/main -I/tmp/pear/temp/amqp -   I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -   I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -   D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -DHAVE_CONFIG_H  -g -O2   -c     /tmp/pear/temp/amqp/amqp_exchange.c -o amqp_exchange.lo
libtool: compile:  cc -I. -I/tmp/pear/temp/amqp -DPHP_ATOM_INC -I/tmp/pear/temp/pear-   build-rootZNUmac/amqp-1.0.0/include -I/tmp/pear/temp/pear-build-rootZNUmac/amqp-1.0.0/main -  I/tmp/pear/temp/amqp -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -  I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -   D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -g -O2 -c   /tmp/pear/temp/amqp/amqp_exchange.c  -fPIC -DPIC -o .libs/amqp_exchange.o
/bin/bash /tmp/pear/temp/pear-build-rootZNUmac/amqp-1.0.0/libtool --mode=compile cc  -I.  -I/tmp/pear/temp/amqp -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootZNUmac/amqp- 1.0.0/include -I/tmp/pear/temp/pear-build-rootZNUmac/amqp-1.0.0/main -I/tmp/pear/temp/amqp -  I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM - I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib - D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -DHAVE_CONFIG_H  -g -O2   -c  /tmp/pear/temp/amqp/amqp_queue.c -o amqp_queue.lo
libtool: compile:  cc -I. -I/tmp/pear/temp/amqp -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootZNUmac/amqp-1.0.0/include -I/tmp/pear/temp/pear-build-rootZNUmac/amqp-1.0.0/main -   I/tmp/pear/temp/amqp -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -  I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -   D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -g -O2 -c            /tmp/pear/temp/amqp/amqp_queue.c  -fPIC -DPIC -o .libs/amqp_queue.o
/tmp/pear/temp/amqp/amqp_queue.c: In function 'read_message_from_channel':
/tmp/pear/temp/amqp/amqp_queue.c:316:11: error: 'AMQP_FIELD_KIND_U64' undeclared (first use in this function)
/tmp/pear/temp/amqp/amqp_queue.c:316:11: note: each undeclared identifier is reported only once for each function it appears in
/tmp/pear/temp/amqp/amqp_queue.c: In function 'zim_amqp_queue_class_nack':
/tmp/pear/temp/amqp/amqp_queue.c:1020:2: error: unknown type name 'amqp_basic_nack_t'
/tmp/pear/temp/amqp/amqp_queue.c:1039:3: error: request for member 'delivery_tag' in something not a structure or union
/tmp/pear/temp/amqp/amqp_queue.c:1040:3: error: request for member 'multiple' in something not a structure or union
/tmp/pear/temp/amqp/amqp_queue.c:1041:3: error: request for member 'requeue' in something not a structure or union
/tmp/pear/temp/amqp/amqp_queue.c:1046:3: error: 'AMQP_BASIC_NACK_METHOD' undeclared     (first use in this function)
make: *** [amqp_queue.lo] Error 1
ERROR: `make' failed

回答1:


It looks like the PECL extension is newer than the the libraries that you have got installed. Install RabbitMQ directly from the their website, using their packages and not the ones that have come with your distribution as they seems to be out of date.




回答2:


I had to install it applying following steps found here:

 # Download the rabbitmq-c library @ version 0-9-1
 git clone git://github.com/alanxz/rabbitmq-c.git
 cd rabbitmq-c
 # Enable and update the codegen git submodule
 git submodule init
 git submodule update
 # Configure, compile and install
 autoreconf -i && ./configure && make && sudo make install

After that, sudo pecl install amqp did the work.

Using Ubuntu 12.10 with PHP 5.4.3.




回答3:


this is what I did to install it successfully on debian wheezy:

apt-get install pkg-config librabbitmq-dev librabbitmq0

git clone https://github.com/alanxz/rabbitmq-c
cd rabbitmq-c/
autoreconf -i
./configure
make
make install
pecl install amqp



回答4:


The dev lib from repo is broken (as usually....). You have to clone (from GIT or HG) and make the lib, from php.net :

hg clone http://hg.rabbitmq.com/rabbitmq-c/rev/b01825ecc112 rabbitmq-c
cd rabbitmq-c
# Add the codegen requirement. To find the full list, go here: http://hg.rabbitmq.com/rabbitmq-codegen/tags
# and copy the URL for the appropriate broker version.
hg clone http://hg.rabbitmq.com/rabbitmq-codegen/rev/16bbcb711380 codegen
# Configure, compile and install
autoreconf -i && ./configure && make && sudo make install

Then run "pecl install amqp", worked in my ubuntu 12 with Php 5.3




回答5:


This is what I did to install it successfully on debian wheezy: I had to use version 0.5.2 of rabbitmq-c

git clone https://github.com/alanxz/rabbitmq-c
cd rabbitmq-c
git checkout tags/v0.5.2
git submodule init
git submodule update
autoreconf -i && ./configure && make && make install
pecl install amqp



回答6:


This is because your rabbitmq is older than the version the php extension requires.

You can install newer version of rabbitmq or lower version of the extension like:

pecl install amqp-1.2.0

But I think using latest versions is better choice.




回答7:


Installing rabbitmq's AMQP with pecl with PHP7.0

Just follow few these steps, this will install all its dependencies and amqp library. It works for me with bento/ubuntu-16.04 with php7.0

apt-get update

wget http://in.archive.ubuntu.com/ubuntu/ubuntu/pool/universe/libr/librabbitmq/librabbitmq1_0.5.2-2_amd64.deb
dpkg -i librabbitmq1_0.5.2-2_amd64.deb

wget http://in.archive.ubuntu.com/ubuntu/ubuntu/pool/universe/libr/librabbitmq/librabbitmq-dev_0.5.2-2_amd64.deb
dpkg -i librabbitmq-dev_0.5.2-2_amd64.deb

apt-get install php7.0 php7.0-mbstring php7.0-mcrypt php7.0-mysql php7.0-xml php7.0-dev

pecl install amqp

echo "extension=amqp.so" >> /etc/php/7.0/cli/php.ini
echo "extension=amqp.so" >> /etc/php/7.0/fpm/php.ini

Librabbitmq-dev and its dependencies of different versions it can be downloaded from

http://in.archive.ubuntu.com/ubuntu/ubuntu/pool/universe/libr/librabbitmq/



来源:https://stackoverflow.com/questions/9520914/installing-amqp-through-pecl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!