我正在尝试使用librdkafka库
使用gcc编译我的程序我收到这种错误未定义的对sasl_something的引用
// usr / local / lib / librdkafka.a(rdkafka_sasl_cyrus.o):在函数
rd_kafka_sasl_cyrus_close': /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:409: undefined reference to
sasl_dispose'中 //usr/local/lib/librdkafka.a(rdkafka_sasl_cyrus.o):在函数rd_kafka_sasl_cyrus_recv': /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:74: undefined reference to
sasl_client_step'中 /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:100:对sasl_errdetail' /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:112: undefined reference to
sasl_getprop'的未定义引用 /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:116:对sasl_getprop' /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:120: undefined reference to
sasl_getprop'的未定义引用 //usr/local/lib/librdkafka.a(rdkafka_sasl_cyrus.o):在函数rd_kafka_sasl_cyrus_client_new': /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:462: undefined reference to
sasl_client_new'中 /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:484:对sasl_client_start' /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:502: undefined reference to
sasl_errdetail'的未定义引用 /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:473:对sasl_listmech' /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:466: undefined reference to
sasl_errstring'的未定义引用 //usr/local/lib/librdkafka.a(rdkafka_sasl_cyrus.o):在函数rd_kafka_sasl_cyrus_global_init': /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:604: undefined reference to
sasl_client_init'中 /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:606:对`sasl_errstring'的未定义引用
我的makefile看起来像这样
LIBS = -L ../utils -lutils -L ../network -lnetwork -Wl,-Bstatic -lev -ljansson -lmpdec -lrdkafka -lrdkafka ++ -lz -llz4 -lssl -lcrypto -lhiredis -Wl, - Bdynamic -lm -lpthread -ldl -lcurl -lstdc ++
我确信这些库有些东西,但无法确定究竟是什么,
也许使用pkg-config rdkafka可以解决问题,但我不知道如何在这里使用它。
你能告诉我吗?
答案 0 :(得分:2)
Cyryus SASL没有关联。库通常被命名为sasl2,因此添加 -lsasl2 应该可以解决问题。
我刚刚在我的系统上安装了rdkafka(Gentoo Linux),它的pkg-config文件包含-lsasl2。是的使用pkg-config也可以解决所描述的问题。
了解如何在makefile here中使用pkg-config。
要使私人图书馆使用:
LDFLAGS += `pkg-config rdkafka --libs --static`