0

I built casablanca for Android per the instructions here: How to build and setup for Android on Linux (2.3+).

I moved the compiled libraries to my Android project and linked the module that depends on casablanca per the instructions here: How to use the C++ REST SDK on Android (2.3+).

However, I get multiple linker errors.

For example, when trying to use

json::value::string( "some value" );

I get,

error: undefined reference to 'web::json::value::string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)'

And when trying to use

json::value version;
version[someValue] = something;

I get,

error: undefined reference to 'web::json::value::operator[](std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'

I am compiling my Android project with clang.

I built on a Linux-64 VM and my Android project is on a Windows-64 machine. However, when trying to build a shared library of casablanca for Android on Linux, I also got multiple linker errors.

I suspect that there is some code being compiled with libstdc++ and some with libc++. From looking at the build scripts, I can see that clang is being used for both boost and casablanca but I also see include paths pointing to gcc headers. I'm also curious as to why I see on the linker output (on Windows) references to /sources/cxx-stl/gnu-libstdc++/4.8/include/ with my Linux VM path.

Any insights on how to get casablanca to link properly on Android will be appreciated.

Thanks.

(I posted this same question here.)

Luis
  • 2,863
  • 1
  • 22
  • 39

2 Answers2

0

It turns out that casablanca needs to be linked against libstdc++ but I am using clang for the project.

So I made the following changes to link my project module to casablanca.

I changed APP_STL from c++_static to c++_shared in Application.mk.

Also, on the Android.mk file where I have the dependencies modules I added the following:

#GNU STL 
#Note: this is the GNU STL static library used by casablanca
include $(CLEAR_VARS)
LOCAL_MODULE    :=  gnustl
LOCAL_SRC_FILES :=  ${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.8/libs/$(TARGET_ARCH_ABI)/libgnustl_static.a
include $(PREBUILT_STATIC_LIBRARY)

#Casablance prebuilt
#Note: These are the includes that casablanca uses.
include $(CLEAR_VARS)
LOCAL_MODULE    :=  casablanca
LOCAL_SRC_FILES :=  $(LOCAL_PATH)/$(TARGET_ARCH_ABI)/libcpprest.a
LOCAL_EXPORT_C_INCLUDES := ${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.8/include \
                           ${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.8/libs/$(TARGET_ARCH_ABI)/include \
                           ${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.8/include/backward
LOCAL_WHOLE_STATIC_LIBRARIES := gnustl
include $(PREBUILT_STATIC_LIBRARY)

In addition, I add the following to the Android.mk for the module dependent on casablanca (since it depends on the system logging library):

LOCAL_LDLIBS    := -llog
Luis
  • 2,863
  • 1
  • 22
  • 39
0

Actually ended up compiling the project code with libstdc++ (gnustl_shared).

Luis
  • 2,863
  • 1
  • 22
  • 39