Closed hikingmoose closed 4 years ago
Are you sure that you are using protobuf-c 1.3.2? Because you are pointing to library 1.0.0:
-DNATS_PROTOBUF_LIBRARY=/usr/local/lib/libprotobuf-c.so.1.0.0
Which platform are you building on? If libprotobuf is installed, you should not have to specify any of the -D DNATS_PROTOBUF_xxx
param.
Hmm...that's a good point. I built and installed protobuf-c 1.3.2 (Did not have any other versions installed previously) and that is what it installed (timestamp is correct and everything). Not sure why they use that naming convention.
I am building on CentOS 7.6.
I just tried again without the -D params and you are right that it finds the libs without it, but I still get the same errors unfortunately. I also tried building nats.c-2.0.0 with the same result.
[ 77%] Building C object src/CMakeFiles/nats_static.dir/stan/sub.c.o Linking C static library libnats_static.a [ 77%] Built target nats_static Scanning dependencies of target nats-asynctimeout [ 78%] Building C object examples/CMakeFiles/nats-asynctimeout.dir/asynctimeout.c.o Linking C executable nats-asynctimeout ../src/libnats.so.2.1.0: undefined reference to "protobuf_c_message_pack" ../src/libnats.so.2.1.0: undefined reference to "protobuf_c_empty_string" ../src/libnats.so.2.1.0: undefined reference to "protobuf_c_message_get_packed_size" ../src/libnats.so.2.1.0: undefined reference to "protobuf_c_message_free_unpacked" ../src/libnats.so.2.1.0: undefined reference to "protobuf_c_message_pack_to_buffer" ../src/libnats.so.2.1.0: undefined reference to "protobuf_c_message_unpack" collect2: error: ld returned 1 exit status make[2]: [examples/nats-asynctimeout] Error 1 make[1]: [examples/CMakeFiles/nats-asynctimeout.dir/all] Error 2 make: *** [all] Error 2
UPDATE: Recompiled with -DNATS_BUILD_EXAMPLES=OFF and I get a little further but still getting errors about protobuf [ 96%] Building C object src/CMakeFiles/nats_static.dir/stan/sub.c.o Linking C static library libnats_static.a [ 96%] Built target nats_static Scanning dependencies of target testsuite [ 98%] Building C object test/CMakeFiles/testsuite.dir/test.c.o Linking C executable testsuite ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbpub_msg__init": protocol.pb-c.c:(.text+0x1a): undefined reference to "protobuf_c_empty_string" protocol.pb-c.c:(.text+0x22): undefined reference to "protobuf_c_empty_string" protocol.pb-c.c:(.text+0x2a): undefined reference to "protobuf_c_empty_string" protocol.pb-c.c:(.text+0x32): undefined reference to "protobuf_c_empty_string" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbpub_ackinit": protocol.pb-c.c:(.text+0x8a): undefined reference to "protobuf_c_empty_string" ../src/libnats_static.a(protocol.pb-c.c.o):protocol.pb-c.c:(.text+0x92): more undefined references to "protobuf_c_empty_string" follow ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbpub_msgget_packed_size": protocol.pb-c.c:(.text+0x361): undefined reference to "protobuf_c_message_get_packed_size" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbpub_msgpack": protocol.pb-c.c:(.text+0x371): undefined reference to "protobuf_c_message_pack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbpub_msgpack_to_buffer": protocol.pb-c.c:(.text+0x381): undefined reference to "protobuf_c_message_pack_to_buffer" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbpub_msgunpack": protocol.pb-c.c:(.text+0x39f): undefined reference to "protobuf_c_message_unpack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbpub_msgfree_unpacked": protocol.pb-c.c:(.text+0x3b6): undefined reference to "protobuf_c_message_free_unpacked" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbpub_ackget_packed_size": protocol.pb-c.c:(.text+0x3d1): undefined reference to "protobuf_c_message_get_packed_size" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbpub_ackpack": protocol.pb-c.c:(.text+0x3e1): undefined reference to "protobuf_c_message_pack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbpub_ackpack_to_buffer": protocol.pb-c.c:(.text+0x3f1): undefined reference to "protobuf_c_message_pack_to_buffer" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbpub_ackunpack": protocol.pb-c.c:(.text+0x40f): undefined reference to "protobuf_c_message_unpack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbpub_ackfree_unpacked": protocol.pb-c.c:(.text+0x426): undefined reference to "protobuf_c_message_free_unpacked" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbmsg_protoget_packed_size": protocol.pb-c.c:(.text+0x441): undefined reference to "protobuf_c_message_get_packed_size" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbmsg_protopack": protocol.pb-c.c:(.text+0x451): undefined reference to "protobuf_c_message_pack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbmsg_protopack_to_buffer": protocol.pb-c.c:(.text+0x461): undefined reference to "protobuf_c_message_pack_to_buffer" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbmsg_protounpack": protocol.pb-c.c:(.text+0x47f): undefined reference to "protobuf_c_message_unpack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbmsg_protofree_unpacked": protocol.pb-c.c:(.text+0x496): undefined reference to "protobuf_c_message_free_unpacked" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbackget_packed_size": protocol.pb-c.c:(.text+0x4b1): undefined reference to "protobuf_c_message_get_packed_size" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbackpack": protocol.pb-c.c:(.text+0x4c1): undefined reference to "protobuf_c_message_pack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbackpack_to_buffer": protocol.pb-c.c:(.text+0x4d1): undefined reference to "protobuf_c_message_pack_to_buffer" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbackunpack": protocol.pb-c.c:(.text+0x4ef): undefined reference to "protobuf_c_message_unpack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbackfree_unpacked": protocol.pb-c.c:(.text+0x506): undefined reference to "protobuf_c_message_free_unpacked" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbconnect_requestget_packed_size": protocol.pb-c.c:(.text+0x521): undefined reference to "protobuf_c_message_get_packed_size" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbconnect_requestpack": protocol.pb-c.c:(.text+0x531): undefined reference to "protobuf_c_message_pack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbconnect_requestpack_to_buffer": protocol.pb-c.c:(.text+0x541): undefined reference to "protobuf_c_message_pack_to_buffer" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbconnect_requestunpack": protocol.pb-c.c:(.text+0x55f): undefined reference to "protobuf_c_message_unpack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbconnect_requestfree_unpacked": protocol.pb-c.c:(.text+0x576): undefined reference to "protobuf_c_message_free_unpacked" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbconnect_responseget_packed_size": protocol.pb-c.c:(.text+0x591): undefined reference to "protobuf_c_message_get_packed_size" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbconnect_responsepack": protocol.pb-c.c:(.text+0x5a1): undefined reference to "protobuf_c_message_pack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbconnect_responsepack_to_buffer": protocol.pb-c.c:(.text+0x5b1): undefined reference to "protobuf_c_message_pack_to_buffer" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbconnect_responseunpack": protocol.pb-c.c:(.text+0x5cf): undefined reference to "protobuf_c_message_unpack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbconnect_responsefree_unpacked": protocol.pb-c.c:(.text+0x5e6): undefined reference to "protobuf_c_message_free_unpacked" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbpingget_packed_size": protocol.pb-c.c:(.text+0x601): undefined reference to "protobuf_c_message_get_packed_size" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbpingpack": protocol.pb-c.c:(.text+0x611): undefined reference to "protobuf_c_message_pack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbpingpack_to_buffer": protocol.pb-c.c:(.text+0x621): undefined reference to "protobuf_c_message_pack_to_buffer" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbpingunpack": protocol.pb-c.c:(.text+0x63f): undefined reference to "protobuf_c_message_unpack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbpingfree_unpacked": protocol.pb-c.c:(.text+0x656): undefined reference to "protobuf_c_message_free_unpacked" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbping_responseget_packed_size": protocol.pb-c.c:(.text+0x671): undefined reference to "protobuf_c_message_get_packed_size" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbping_responsepack": protocol.pb-c.c:(.text+0x681): undefined reference to "protobuf_c_message_pack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbping_responsepack_to_buffer": protocol.pb-c.c:(.text+0x691): undefined reference to "protobuf_c_message_pack_to_buffer" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbping_responseunpack": protocol.pb-c.c:(.text+0x6af): undefined reference to "protobuf_c_message_unpack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbping_responsefree_unpacked": protocol.pb-c.c:(.text+0x6c6): undefined reference to "protobuf_c_message_free_unpacked" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbsubscription_requestget_packed_size": protocol.pb-c.c:(.text+0x6e1): undefined reference to "protobuf_c_message_get_packed_size" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbsubscription_requestpack": protocol.pb-c.c:(.text+0x6f1): undefined reference to "protobuf_c_message_pack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbsubscription_requestpack_to_buffer": protocol.pb-c.c:(.text+0x701): undefined reference to "protobuf_c_message_pack_to_buffer" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbsubscription_requestunpack": protocol.pb-c.c:(.text+0x71f): undefined reference to "protobuf_c_message_unpack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbsubscription_requestfree_unpacked": protocol.pb-c.c:(.text+0x736): undefined reference to "protobuf_c_message_free_unpacked" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbsubscription_responseget_packed_size": protocol.pb-c.c:(.text+0x751): undefined reference to "protobuf_c_message_get_packed_size" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbsubscription_responsepack": protocol.pb-c.c:(.text+0x761): undefined reference to "protobuf_c_message_pack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbsubscription_responsepack_to_buffer": protocol.pb-c.c:(.text+0x771): undefined reference to "protobuf_c_message_pack_to_buffer" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbsubscription_responseunpack": protocol.pb-c.c:(.text+0x78f): undefined reference to "protobuf_c_message_unpack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbsubscription_responsefree_unpacked": protocol.pb-c.c:(.text+0x7a6): undefined reference to "protobuf_c_message_free_unpacked" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbunsubscribe_requestget_packed_size": protocol.pb-c.c:(.text+0x7c1): undefined reference to "protobuf_c_message_get_packed_size" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbunsubscribe_requestpack": protocol.pb-c.c:(.text+0x7d1): undefined reference to "protobuf_c_message_pack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbunsubscribe_requestpack_to_buffer": protocol.pb-c.c:(.text+0x7e1): undefined reference to "protobuf_c_message_pack_to_buffer" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbunsubscribe_requestunpack": protocol.pb-c.c:(.text+0x7ff): undefined reference to "protobuf_c_message_unpack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbunsubscribe_requestfree_unpacked": protocol.pb-c.c:(.text+0x816): undefined reference to "protobuf_c_message_free_unpacked" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbclose_requestget_packed_size": protocol.pb-c.c:(.text+0x831): undefined reference to "protobuf_c_message_get_packed_size" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbclose_requestpack": protocol.pb-c.c:(.text+0x841): undefined reference to "protobuf_c_message_pack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbclose_requestpack_to_buffer": protocol.pb-c.c:(.text+0x851): undefined reference to "protobuf_c_message_pack_to_buffer" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbclose_requestunpack": protocol.pb-c.c:(.text+0x86f): undefined reference to "protobuf_c_message_unpack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbclose_requestfree_unpacked": protocol.pb-c.c:(.text+0x886): undefined reference to "protobuf_c_message_free_unpacked" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbclose_responseget_packed_size": protocol.pb-c.c:(.text+0x8a1): undefined reference to "protobuf_c_message_get_packed_size" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbclose_responsepack": protocol.pb-c.c:(.text+0x8b1): undefined reference to "protobuf_c_message_pack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbclose_responsepack_to_buffer": protocol.pb-c.c:(.text+0x8c1): undefined reference to "protobuf_c_message_pack_to_buffer" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbclose_responseunpack": protocol.pb-c.c:(.text+0x8df): undefined reference to "protobuf_c_message_unpack" ../src/libnats_static.a(protocol.pb-c.c.o): In function "pbclose_response__free_unpacked": protocol.pb-c.c:(.text+0x8f6): undefined reference to "protobuf_c_message_free_unpacked" ../src/libnats_static.a(protocol.pb-c.c.o):(.rodata+0x228): undefined reference to "protobuf_c_empty_string" ../src/libnats_static.a(protocol.pb-c.c.o):(.rodata+0x328): undefined reference to "protobuf_c_empty_string" ../src/libnats_static.a(protocol.pb-c.c.o):(.rodata+0x428): undefined reference to "protobuf_c_empty_string" ../src/libnats_static.a(protocol.pb-c.c.o):(.rodata+0x470): undefined reference to "protobuf_c_empty_string" ../src/libnats_static.a(protocol.pb-c.c.o):(.rodata+0x4b8): undefined reference to "protobuf_c_empty_string" ../src/libnats_static.a(protocol.pb-c.c.o):(.rodata+0x500): more undefined references to "protobuf_c_empty_string" follow collect2: error: ld returned 1 exit status make[2]: [test/testsuite] Error 1 make[1]: [test/CMakeFiles/testsuite.dir/all] Error 2 make: *** [all] Error 2
If you have install protobuf-c just for this test, what you could do is this: uninstall (remove it) and instead git clone the dependencies repo that I use to build on Travis: https://github.com/nats-io/nats.c.deps.
Clean your build repo (rm CMakeCache.txt) and then cmake .. -DNATS_PROTOBUF_DIR=<dir to where you have cloned the said repo>/pbuf
. Let me know if this helps.
Interestingly enough it finds libprotobuf-c in that pbuf folder but says it can't find the protobuf-c.h until I put it back in /usr/local/include.
Any chance this could be related to a gcc issue? -- The C compiler identification is GNU 4.8.5 -- The CXX compiler identification is GNU 4.8.5 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Found OpenSSL: /usr/lib64/libssl.so;/usr/lib64/libcrypto.so (found version "1.0.2k")
I tried on a CentOS docker image and using NATS C Client master branch. The installed version of protobuf-c(-devel) was definitively too old. I then uninstall and pointed to the dependency repo I mentioned. The weird part is that the code I have in CMakeFiles.txt to detect the libprotobuf-c or pass the NATS_PROTOBUF_DIR/LIBRARY to command line works perfectly on macOS, Windows and Linux (Ubuntu), actually used in the Tavis build, but did not work on CentOS. I had to manually edit the CMakeFiles.txt to set the NATS_PROTOBUF_INCLUDE_DIRS
and NATS_PROTOBUF_LIBRARIES
params, and then it worked.
Were you able to compile the library or not?
I was just able to get it to build by setting: option(NATS_BUILD_EXAMPLES "Build examples" OFF) And also removing these two test sub-directories in the CMakeFiles.txt add_subdirectory(test) add_subdirectory(test/dylib)
but then I just tried your method for manually setting the params and it works without needing to change anything else! Thanks for taking a look into this!
When trying to build nats.c-2.1.0 w/ streaming enabled I am getting the following errors (Currently using protobuf-c-1.3.2)
Ran the following commands: cmake .. -DNATS_PROTOBUF_DIR=/usr/local/include -DNATS_PROTOBUF_LIBRARY=/usr/local/lib/libprotobuf-c.so.1.0.0 -DNATS_BUILD_WITH_TLS=OFF make install Errors: ../src/libnats.so.2.1.0: undefined reference to "protobuf_c_empty_string" ../src/libnats.so.2.1.0: undefined reference to "protobuf_c_message_pack" ../src/libnats.so.2.1.0: undefined reference to "protobuf_c_message_pack_to_buffer" ../src/libnats.so.2.1.0: undefined reference to "protobuf_c_message_unpack" ../src/libnats.so.2.1.0: undefined reference to "protobuf_c_message_get_packed_size" ../src/libnats.so.2.1.0: undefined reference to "protobuf_c_message_free_unpacked"
Note: it was able to find the library "-- Found libprotobuf-c: /usr/local/include" and it is not complaining that it can't find the protobuf-c.h file, just that it has undefined references. I also tried nats.c-2.0.0 and different versions of protobuf-c but have issues no matter what combination I use, until I go back to nats.c-1.8.0 where it came packaged together.