libhdfspp
libhdfspp copied to clipboard
hdfsppjni.so undefined symbols
Cmake avoids static linkages unless explicitly instructed. Running mvn package would crash the JVM when the JNI couldn't find various protobuf symbols.
using: gcc 4.8.2 cmake 2.8.12.2 ubuntu 14.04 x86_64
Running objdump -T libhdfsppjni.so | grep UND shows lots of symbols from libproto.a are declared but not defined.
These can be found with objdump -D libproto.a | grep various_undefined_protobuf_symbols.
The simple fix is to explicitly pass linker options to make sure that the static libraries are built into the shared object rather than just referenced with the assumption that they will be linked later.
The change in /src/main/native/bindings/java/CMakeLists.txt would be adding "-Wl,--whole-archive" here:
target_link_libraries(hdfsppjni "-Wl,--whole-archive" common reader proto rpc "-Wl,--no-whole-archive" ${PROTOBUF_LIBRARIES} ${OPENSSL_LIBRARIES})
I have this fixed, will submit a pull request after I rebase; need to take a few minutes to figure that out.