-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dynamic linking doesn't work #95
Comments
Hey, that's weird.
Thanks |
putting -lrdkafka at the end of the gcc arguments list works. |
Great! Some (older) gcc versions are pickier than others on linking order. |
I'm having some linking issues with version 5d8d4f0 I can only seem to get it to link to the static libraries. Using the dynamic libraries I get a bunch of undefined reference errors. I tried compiling the cpp example using the dynamic libs but this results in the same errors. I compile the example using static libs using: /usr/bin/c++ -g -O2 -fPIC -Wall -Werror -Wfloat-equal -Wpointer-arith -Wno-non-virtual-dtor -I/home/user/dev/install/kafka/include/librdkafka rdkafka_example.cpp -o rdkafka_example_cpp -g ../src-cpp/librdkafka++.a ../src/librdkafka.a -lpthread -lz -lstdc++ That works fine. When trying to compile the cpp example using the dynamic libs: /usr/bin/c++ -g -O2 -fPIC -Wall -Werror -Wfloat-equal -Wpointer-arith -Wno-non-virtual-dtor -I/home/user/dev/install/kafka/include/librdkafka rdkafka_example.cpp -L/home/user/dev/install/kafka/lib -o rdkafka_example_cpp -lpthread -lz -lstdc++ -lrdkafka++ -lrdkafka /tmp/ccrQv7rs.o: In function Note that /home/user/dev/install/kafka/lib contains the installed libs. |
The linker script for the C library was run on the C++ library, hiding all of the C++ symbols. Fixed in latest master. Thanks for reporting this! |
I am still getting same compilation error as above while trying to build with gcc compiler the librdkafka cpp example code. ./Librdkafkaexample.o: In function Even though all the libraries are included and the linkers as given in documentation i get this error. Can anyone help? |
Please provide your linking command line. |
@edenhill I used Eclipse IDE that generated this command on console: I set the linker to have -lz as well as per your documentation in the github project but that gave error as :
|
You dont seem to be linking with the C++ library, try: -lrdkafka++ |
Thanks a ton @edenhill . It worked and now the project is building. Thanks again for the quick response. |
Hello, ./configure --prefix=/home/gateway/kafkalib I created kafka.conf under ld.so.conf.d folder. (content: /home/gateway/kafkalib) gcc -O3 Wall -lrdkafka -lz -lpthread -lrt kafkaexample.c |
You need to put the libraries at the end of the command line: |
The same error occurs again. |
Would you mind pasting the actual error message? |
Line 11: #include "rdkafka.h" Error : |
If you've installed librdkafka to a non-standard location you'll also need to provide the include path to the compiler, e.g.:
|
Error : |
These are pretty basic C compilation/building concepts and are outside the scope of librdkafka open source support.
|
Final code is like below and it worked successfully. gcc -O3 -Wall -L/home/gateway/kafkalib/lib -lrdkafka -lz -lpthread -lrt -I/home/gateway/kafkalib/include/librdkafka kafkaexample.c |
You have an incorrect include path: |
Thank you very much, it worked for me 😁. I was stuck on that for a week 😅 |
Hi Team, [root@EC2AMAZ-ROPJ2S kafka2]# gcc -Wall -o producer producer.c -I/usr/bin/include -lrdkafka -lz -lpthread -lrt |
Hello,
If I try to use dynamic link I always get undefined references.
I installed the libraries in /usr/local/lib ane try to compile rdkafka_example.c using
gcc -I/usr/local/include/librdkafka -L/usr/local/lib -lrdkafka rdkafka_example.c
But I get link errors
/tmp/cczYMsjA.o: In function
rd_kafka_message_errstr': rdkafka_example.c:(.text+0x31): undefined reference to
rd_kafka_err2str'/tmp/cczYMsjA.o: In function
logger': rdkafka_example.c:(.text+0x1f0): undefined reference to
rd_kafka_name'/tmp/cczYMsjA.o: In function
msg_delivered': rdkafka_example.c:(.text+0x263): undefined reference to
rd_kafka_err2str'/tmp/cczYMsjA.o: In function
msg_consume': rdkafka_example.c:(.text+0x2e7): undefined reference to
rd_kafka_topic_name'rdkafka_example.c:(.text+0x357): undefined reference to
rd_kafka_topic_name' /tmp/cczYMsjA.o: In function
metadata_print':rdkafka_example.c:(.text+0x5ba): undefined reference to
rd_kafka_err2str' rdkafka_example.c:(.text+0x6fc): undefined reference to
rd_kafka_err2str'/tmp/cczYMsjA.o: In function
sig_usr1': rdkafka_example.c:(.text+0x765): undefined reference to
rd_kafka_dump'/tmp/cczYMsjA.o: In function
main': rdkafka_example.c:(.text+0x7ea): undefined reference to
rd_kafka_conf_new'rdkafka_example.c:(.text+0x7f3): undefined reference to
rd_kafka_topic_conf_new' rdkafka_example.c:(.text+0x887): undefined reference to
rd_kafka_conf_set'.....
The text was updated successfully, but these errors were encountered: