我正在尝试用C语言为Apache Kafka编写PHP扩展,它应该使用librdkafka。因此,我编译并安装了kafka客户端库,并编写了包含librdkafka/rdkafka.h的简单扩展,并且扩展与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
有什么帮助吗?
你的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