I'm trying to compile an open source project (let's say foo
) into a libfoo.so
native library to use for my android app. However, this project also uses google's protocol buffer library.
So i was able to compile Google's lib protobuf for iOS as follows: https://gist.github.com/BennettSmith/7150245 .
However, this just generates libprotobuf.a
file. The problem is that I can't seem to figure out a way to include this libprotobuf.a
file to my libfoo.so
file for use with my android application. I THOUGHT i had referenced it when i did:
include $(CLEAR_VARS)
LOCAL_MODULE := libprotobuf
LOCAL_SRC_FILES := ./src/lib/libprotobuf.a
LOCAL_EXPORT_C_INCLUDES := ./src/include
include $(PREBUILT_STATIC_LIBRARY)
in my Android.mk
file. However, it seems that it is definitely not getting linked properly. Whenever i try to ndk-build
the open source project (which depends on using lib protobuf), i get a bunch of undefined references, like:
undefined reference to 'google::protobuf::internal::empty_string_'
so then i thought that maybe i'm not supposed to have the symbols defined here? like maybe i'm supposed to first compile the libfoo.so
file, and then somehow link lib protobuf as libprotobuf.a
or libprotobuf.so
?? so i ended up using LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
to just get my project to generate the libfoo.so
file.
but this libfoo.so
gives me some load error as soon as i try to use it within my android app:
dlopen failed: cannot locate symbol "_ZN6google8protobuf11MessageLite15ParseFromStringERKSs" referenced by libfoo.so
So I'm wondering:
- How do i include this protobuf library in my android app?
- Do i try to include this protobuf library into
libfoo.so
first? - Would it even work if i tried to ignore linker warnings and then tried to generate
libprotobuf.so
and include that with my application? - is it even possible to generate
libprotobuf.so
? I can't generate it using the instructions on their github - i get a ton of errors
Note that the only reason i'm even able to get undefined reference
errors when trying to generate libfoo.so
is because i manually copied all of the *.h
in google's lib protobuf.
Any help would be greatly appreciated!!!