1

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 ?

Ilan
  • 479
  • 7
  • 17
  • Symbols from cyrus-sasl library are unknown. Adding -lsasl2 should fix the problem. – ptrlukas Mar 23 '18 at 20:24
  • 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 Mar 24 '18 at 10:45
  • 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 Mar 24 '18 at 10:56

1 Answers1

2

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`
ptrlukas
  • 246
  • 1
  • 8
  • Thanks but how do you use pkg-config in the makefile ? – Ilan Mar 24 '18 at 12:12
  • I receive this error when using -lsasl2 : `/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` – Ilan Mar 24 '18 at 12:16
  • Answer improved. I have seen your previous comment about bin2hex. It looks to me like another function named bin2hex is already defined in /home/ilan/program-master/utils/ut_misc.c:181. If it is your own implementation of bin2hex try renaming it. – ptrlukas Mar 24 '18 at 12:43
  • I think that my real issue is that I don't have cyrus sasl installed in the first place, but reading their installation guide, I think I don't have enough level to complete it... I have compilation errors already with them. – Ilan Mar 24 '18 at 18:44
  • It is quite common package. Probably it can be installed with package manager. – ptrlukas Mar 24 '18 at 19:41
  • Like this one ? sudo apt-get install sasl2-bin ? On their website it seems to be much complex – Ilan Mar 24 '18 at 19:55
  • I think it is libsasl2-2. – ptrlukas Mar 24 '18 at 21:05