0
votes

I'm trying to compile my program with gcc using the librdkafka library,

I receive this kind of error undefined reference to sasl_something

//usr/local/lib/librdkafka.a(rdkafka_sasl_cyrus.o): In function rd_kafka_sasl_cyrus_close': /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:409: undefined reference tosasl_dispose' //usr/local/lib/librdkafka.a(rdkafka_sasl_cyrus.o): In function rd_kafka_sasl_cyrus_recv': /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:74: undefined reference tosasl_client_step' /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:100: undefined reference to sasl_errdetail' /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:112: undefined reference tosasl_getprop' /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:116: undefined reference to sasl_getprop' /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:120: undefined reference tosasl_getprop' //usr/local/lib/librdkafka.a(rdkafka_sasl_cyrus.o): In function rd_kafka_sasl_cyrus_client_new': /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:462: undefined reference tosasl_client_new' /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:484: undefined reference to sasl_client_start' /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:502: undefined reference tosasl_errdetail' /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:473: undefined reference to sasl_listmech' /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:466: undefined reference tosasl_errstring' //usr/local/lib/librdkafka.a(rdkafka_sasl_cyrus.o): In function rd_kafka_sasl_cyrus_global_init': /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:604: undefined reference tosasl_client_init' /home/ilan/librdkafka-master/src/rdkafka_sasl_cyrus.c:606: undefined reference to `sasl_errstring'

My makefile looks like this

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++

I'm sure there is something up with the libraries but cannot figure out what exactly,

Maybe using pkg-config rdkafka would resolve the issue, but I don't know how to use it here.

Can you please advise ?

1
Symbols from cyrus-sasl library are unknown. Adding -lsasl2 should fix the problem. - ptrlukas
Thank you, indeed it resolve the issue, but it creates another one /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libsasl2.a(otp.o): In function 'bin2hex': (.text+0xbf0): multiple definition of 'bin2hex' ../utils/libutils.a(ut_misc.o):/home/ilan/program-master/utils/ut_misc.c:181: first defined here It is much longer, but it is that kind of issue - Ilan
I am writing more elaborate answer to your initial question. Is it possible that you have your own implementation of bin2hex function in /home/ilan/program-master/utils/ut_misc.c? - ptrlukas

1 Answers

2
votes

Cyryus SASL is not linked. Library is usually named sasl2, so adding -lsasl2 should fix the problem.

I just installed rdkafka on my system (Gentoo Linux) and its pkg-config file contains -lsasl2. So yes. Using pkg-config should solve described problem too.

See how to use pkg-config in makefile here.

To get also private libraries use:

LDFLAGS  += `pkg-config rdkafka --libs --static`