I'm trying to write a PHP extension for Apache Kafka in C and it should use librdkafka. So, I compiled and installed kafka client library, and wrote simple extension which includes librdkafka/rdkafka.h and extension is compilig fine with phpize, ./configure, make and make install. But when I try to use extension, I'm getting error:
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
So, basically, I think I didn't include librdkafka properly into extension or something related to linking those two programs.
Here is my code: https://github.com/salebab/phpkafka
librdkafka files are here:
/usr/local/lib/librdkafka.so /usr/local/lib/librdkafka.a
Any help?
your config.m4 has problem,this is mine, worked for me:
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