php扩展

js4nwp54  于 2021-06-07  发布在  Kafka
关注(0)|答案(1)|浏览(510)

我正在尝试用c为apachekafka编写一个php扩展,它应该使用librdkafka。因此,我编译并安装了kafka客户机库,并编写了简单的扩展程序,包括librdkafka/rdkafka.h和extension is compileg fine with phpize、./configure、make和make install。但是当我尝试使用扩展时,我得到了一个错误:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/2010052 5+lfs/kafka.so' - /usr/lib/php5/20100525+lfs/kafka.so: undefined symbol: rd_kafk a_topic_new in Unknown on line 0

所以,基本上,我认为我没有将librdkafka恰当地包含在扩展中,或者与链接这两个程序相关的东西中。
这是我的密码:https://github.com/salebab/phpkafka
librdkafka文件如下:

/usr/local/lib/librdkafka.so /usr/local/lib/librdkafka.a

有什么帮助吗?

e4eetjau

e4eetjau1#

你的config.m4有问题,这是我的,为我工作:

PHP_ARG_WITH(kafka, for kafka support, 
 Make sure that the comment is aligned:
 [  --with-kafka             Include kafka support])

 PHP_ADD_INCLUDE("{path_to_rdkafka}/include")

 if test $PHP_KAFKA != "no"; then
  PHP_ADD_LIBRARY_WITH_PATH(rdkafka, {path_to_rdkafka}/lib, KAFKA_SHARED_LIBADD)
  PHP_SUBST(KAFKA_SHARED_LIBADD)
  PHP_NEW_EXTENSION(kafka, kafka.c library.c, $ext_shared)
 fi

相关问题