Linker Errors on Android

Dec 3, 2014 at 1:21 PM
Edited Dec 3, 2014 at 1:28 PM
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.
Dec 3, 2014 at 2:37 PM
Edited Dec 3, 2014 at 2:38 PM
I searched all casablanca files (excluding .log, .a, .so, and .o) for references to
sources/cxx-stl/gnu-libstdc++
Here are the results:
casablanca/Build_android/build/android-cmake/android.toolchain.cmake:1015: $ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a
casablanca/Build_android/build/android-cmake/android.toolchain.cmake:1095: if( EXISTS "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}" )
casablanca/Build_android/build/android-cmake/android.toolchain.cmake:1099: set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.6" )
casablanca/Build_android/build/android-cmake/android.toolchain.cmake:1101: set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}" )
casablanca/Build_android/build/android-cmake/android.toolchain.cmake:1104: set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++" )
casablanca/Build_android/build/android-cmake/android.toolchain.cmake:1117: set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) # r8b or newer
casablanca/Build_android/build/android-cmake/android.toolchain.cmake:1119: set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) # r7-r8
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_49_0.jam:74:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/include/4.6.3
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_49_0.jam:75:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/libs/armeabi/4.6.3/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_49_0.jam:118:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_49_0.jam:119:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_49_0.jam:162:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_49_0.jam:163:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_49_0.jam:205:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_49_0.jam:206:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_48_0.jam:117:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/include/4.6.3
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_48_0.jam:118:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/libs/armeabi/4.6.3/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_48_0.jam:161:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_48_0.jam:162:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_48_0.jam:204:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_48_0.jam:205:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_54_0.jam:75:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_54_0.jam:76:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_54_0.jam:118:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_54_0.jam:119:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_45_0.jam:167:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_45_0.jam:168:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_45_0.jam:211:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/include/4.6.3
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_45_0.jam:212:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/libs/armeabi/4.6.3/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_45_0.jam:258:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_45_0.jam:259:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_55_0.jam:74:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.8/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_55_0.jam:75:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_53_0.jam:76:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_53_0.jam:77:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_53_0.jam:119:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/include
casablanca/Build_android/build/Boost-for-Android/configs/user-config-boost-1_53_0.jam:120:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include
casablanca/Build_android/build/Boost-for-Android/boost_1_55_0/tools/build/v2/user-config.jam:74:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.8/include
casablanca/Build_android/build/Boost-for-Android/boost_1_55_0/tools/build/v2/user-config.jam:75:<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi/include
casablanca/Build_android/build/Boost-for-Android/README.md:95: -L$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/libs/armeabi \
casablanca/Build_android/build/build.armv7.debug/CMakeCache.txt:296:cpprest_LIB_DEPENDS:STATIC=general;casablanca/Build_android/build/build.armv7.debug/../openssl/x86/lib/libssl.a;general;casablanca/Build_android/build/build.armv7.debug/../openssl/x86/lib/libcrypto.a;general;android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/thumb/libgnustl_static.a;general;atomic;general;dl;general;gcc;general;c;general;m;general;-nodefaultlibs;
casablanca/Build_android/build/build.armv7.debug/CMakeCache.txt:299:httpclient_test_LIB_DEPENDS:STATIC=general;httptest_utilities;general;common_utilities;general;unittestpp;general;cpprest;general;android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/thumb/libgnustl_static.a;general;atomic;general;dl;general;gcc;general;c;general;m;general;-nodefaultlibs;
casablanca/Build_android/build/build.armv7.debug/CMakeCache.txt:302:httplistener_test_LIB_DEPENDS:STATIC=general;httptest_utilities;general;common_utilities;general;unittestpp;general;cpprest;general;android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/thumb/libgnustl_static.a;general;atomic;general;dl;general;gcc;general;c;general;m;general;-nodefaultlibs;
casablanca/Build_android/build/build.armv7.debug/CMakeCache.txt:308:json_test_LIB_DEPENDS:STATIC=general;httptest_utilities;general;common_utilities;general;unittestpp;general;cpprest;general;android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/thumb/libgnustl_static.a;general;atomic;general;dl;general;gcc;general;c;general;m;general;-nodefaultlibs;
casablanca/Build_android/build/build.armv7.debug/CMakeCache.txt:311:pplx_test_LIB_DEPENDS:STATIC=general;httptest_utilities;general;common_utilities;general;unittestpp;general;cpprest;general;android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/thumb/libgnustl_static.a;general;atomic;general;dl;general;gcc;general;c;general;m;general;-nodefaultlibs;
casablanca/Build_android/build/build.armv7.debug/CMakeCache.txt:314:streams_test_LIB_DEPENDS:STATIC=general;httptest_utilities;general;common_utilities;general;unittestpp;general;cpprest;general;android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/thumb/libgnustl_static.a;general;atomic;general;dl;general;gcc;general;c;general;m;general;-nodefaultlibs;
casablanca/Build_android/build/build.armv7.debug/CMakeCache.txt:317:unittestpp_LIB_DEPENDS:STATIC=general;android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/thumb/libgnustl_static.a;general;atomic;general;dl;general;gcc;general;c;general;m;general;-nodefaultlibs;
casablanca/Build_android/build/build.armv7.debug/CMakeCache.txt:320:uri_test_LIB_DEPENDS:STATIC=general;httptest_utilities;general;common_utilities;general;unittestpp;general;cpprest;general;android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/thumb/libgnustl_static.a;general;atomic;general;dl;general;gcc;general;c;general;m;general;-nodefaultlibs;
casablanca/Build_android/build/build.armv7.debug/CMakeCache.txt:323:utils_test_LIB
Coordinator
Dec 4, 2014 at 7:47 AM
Edited Dec 4, 2014 at 7:47 AM
Hi luisfeliu,

We should be only referencing and linking against libstdc++; there should be no references to libc++ at all. Just to confirm: you are using the static library version of Casablanca (libcpprest.a), correct?

Secondly, are you compiling for ARM or x86? We currently only support ARM on the master branch, however we are working on x86 support. I recommend compiling for ARM and deploying to a real android device for debugging.

My sincerest apologies that this was not made clear in the documentation. It has been updated to reflect this fact.

roschuma
Dec 4, 2014 at 2:57 PM
Thanks for your response roschuma.

I managed to get my project to link casablanca properly yesterday evening.

I am compiling for both ARM and x86 and it compiled and linked without errors for both architectures. I have yet to run tests, but I suspect that if you are having issues with x86 it is because of an error in the libgnustl_static.a path. I submitted a pull request with a fix for this (FIX LIBGNUSTL_STATIC.A PATH FOR X86).

Yes, so we are compiling with clang but casablanca needs libstdc++. Here's how I handled it.

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:
LOCAL_LDLIBS    := -llog
You should probably add to the documentation that casablanca uses the log library and it needs to be linked to as well.

Thanks.
Marked as answer by luisfeliu on 12/4/2014 at 7:57 AM
Coordinator
Dec 4, 2014 at 5:26 PM
Unfortunately, the issues with x86 will not result in a failure to link. Instead, your shared object file will be mysteriously unable to load at runtime due to missing symbols (assuming you're using the library for anything nontrivial; the simplest of examples will work fine).

However, you're treading into extremely dangerous territory by linking against both libc++ and libstdc++. While you may have gotten things to compile, you're almost guaranteed to run into nightmarish bugs at runtime which simply do not make sense.

Why do you need to link against libc++ at all? Simply setting APP_STL to be gnustl_static should make everything work fine.

Thanks for the catch on -llog. We also likely will require -lm as well.

roschuma
Dec 4, 2014 at 6:10 PM
I have not tested the x86 code yet so thanks for the info.

Our project is more compatible with libc++. Setting APP_STL to gnustl_static would require significant changes to our project code to make it compatible with libstdc++.
Only the module that depends on casablanca uses libstdc++. If testing reveals issues, we may just have to use libstdc++ for our project and make the necessary changes or we will have to compile casablanca with libc++ instead.

Per the NDK documentation the math library is automatically linked to the native modules at build time, so there is no need to list "-lm" through LOCAL_LDLIBS.

Thanks.
Dec 9, 2014 at 8:49 PM
So in the end we decided to change our project code to compile it with libstdc++. Although we had to set APP_STL to gnustl_shared.
Marked as answer by luisfeliu on 12/9/2014 at 1:49 PM
Jan 9, 2015 at 6:26 AM
I want to test the cpprest library on android through SDK emulator, so i builded a executable sample "bingrequest". but link error happens when run this file.

CANNOT LINK EXECUTABLE: cannot locate symbol "___tls_get_addr" referenced by "./bingrequest"...

I searched all the files, the result is :
wangqiang@ubuntu:~/casablanca$ grep ___tls_get_addr * -R
Binary file Build_android/build/build.x86.debug/src/CMakeFiles/cpprest.dir/pplx/linux/pplxlinux.cpp.o matches
Binary file Build_android/build/build.x86.debug/src/CMakeFiles/cpprest.dir/pplx/threadpool.cpp.o matches
Binary file Build_android/build/build.x86.debug/src/CMakeFiles/cpprest.dir/websockets/client/ws_client.cpp.o matches
Binary file Build_android/build/build.x86.debug/src/CMakeFiles/cpprest.dir/http/listener/http_server_api.cpp.o matches
Binary file Build_android/build/build.x86.debug/src/CMakeFiles/cpprest.dir/http/listener/http_linux_server.cpp.o matches
Binary file Build_android/build/build.x86.debug/src/CMakeFiles/cpprest.dir/http/client/x509_cert_utilities.cpp.o matches
Binary file Build_android/build/build.x86.debug/src/CMakeFiles/cpprest.dir/http/client/http_linux.cpp.o matches
Binary file Build_android/build/build.x86.debug/Binaries/libcpprest.a matches
Binary file Build_android/build/build.x86.release/src/CMakeFiles/cpprest.dir/pplx/linux/pplxlinux.cpp.o matches
Binary file Build_android/build/build.x86.release/src/CMakeFiles/cpprest.dir/pplx/threadpool.cpp.o matches
Binary file Build_android/build/build.x86.release/src/CMakeFiles/cpprest.dir/websockets/client/ws_client.cpp.o matches
Binary file Build_android/build/build.x86.release/src/CMakeFiles/cpprest.dir/http/listener/http_server_api.cpp.o matches
Binary file Build_android/build/build.x86.release/src/CMakeFiles/cpprest.dir/http/listener/http_linux_server.cpp.o matches
Binary file Build_android/build/build.x86.release/src/CMakeFiles/cpprest.dir/http/client/x509_cert_utilities.cpp.o matches
Binary file Build_android/build/build.x86.release/src/CMakeFiles/cpprest.dir/http/client/http_linux.cpp.o matches
Binary file Build_android/build/build.x86.release/Binaries/libcpprest.a matches

Is there anyone can help me to resolve this problem, thanks!
Coordinator
Jan 9, 2015 at 9:22 PM
Hi wangqiang,

__tls_get_addr is a symbol created by the compiler whenever you use thread local storage. This can be caused by using ___thread or thread_local. What version of cpprest are you using? We do not support x86 before version 2.4 (due to this very issue).
Jan 12, 2015 at 1:08 AM
Edited Jan 12, 2015 at 4:45 AM
Hi, roschuma,
Thank you for your response.

I'm using cpprest version 2.3 from website: https://github.com/ambroff/casablanca.
When i builded the version2.4 from https://casablanca.codeplex.com/SourceControl/latest,
some errors happened with cmake. (Release/src/CMakeLists.txt line 50)
CMake Error at src/CMakeLists.txt:50 (add_library):
  Cannot find source file:

    $(SOURCES)

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx
Also i can't git clone from the respository:https://git01.codeplex.com/casablanca

Please help me to resolve this issue, thanks~
Coordinator
Jan 12, 2015 at 6:01 PM
Could you try replacing the parentheses around the "SOURCES" with curly braces in the CMakeLists.txt file?
Jan 13, 2015 at 1:00 AM
Edited Jan 13, 2015 at 1:04 AM
I don't know why. The source code of src/CMakeLists.txt in version 2.4 is exactly the same with version 2.3
But the version 2.3 can be built successfully.
The error is printed by CMake, and the source code is (curly braces as default):
......
add_library(${Casablanca_LIBRARY} ${SOURCES})   #this line causes error!

target_link_libraries(${Casablanca_LIBRARY}
  ${CMAKE_THREAD_LIBS_INIT}
  ${Boost_SYSTEM_LIBRARY}
  ${Boost_THREAD_LIBRARY}
  ${Boost_ATOMIC_LIBRARY}
  ${Boost_CHRONO_LIBRARY}
  ${Boost_LOCALE_LIBRARY}
  ${Boost_RANDOM_LIBRARY}
  ${EXTRALINKS}
  ${Boost_FRAMEWORK}
  ${OPENSSL_LIBRARIES}
  ${COREFOUNDATION}
  ${ANDROID_STL_FLAGS}
  )
......
Coordinator
Jan 13, 2015 at 8:56 PM
We recently fixed a bug with this, could you try doing a completely clean checkout and clean build of the development branch?
Jan 14, 2015 at 6:50 AM
Edited Jan 14, 2015 at 7:35 AM
Hi, roschuma, thank you for your help. I can build version 2.4 successfully now.
But when i built executable sample "bingrequest", some link error happened.
wangqiang@ubuntu:~/cpprest/jni$ ~/android-ndk-r10/ndk-build
[x86] Executable     : bingrequest
/home/wangqiang/cpprest/jni/../include/pplx/pplxcancellation_token.h:231: error: undefined reference to 'pplx::details::platform::GetCurrentThreadId()'
/home/wangqiang/cpprest/jni/../include/pplx/pplxcancellation_token.h:563: error: undefined reference to 'pplx::details::platform::GetCurrentThreadId()'
/home/wangqiang/cpprest/jni/../include/pplx/pplxlinux.h:213: error: undefined reference to 'pplx::details::platform::GetCurrentThreadId()'
/home/wangqiang/cpprest/jni/../include/pplx/pplxlinux.h:213: error: undefined reference to 'pplx::details::platform::GetCurrentThreadId()'
/home/wangqiang/casablanca/Release/src/pplx/pplx.cpp:61: error: undefined reference to 'pplx::details::platform::YieldExecution()'
/home/wangqiang/casablanca/Release/include/pplx/pplxlinux.h:250: error: undefined reference to 'vtable for pplx::details::linux_scheduler'
/home/wangqiang/android-ndk-r10/toolchains/x86-4.8/prebuilt/linux-x86_64/lib/gcc/i686-linux-android/4.8/../../../../i686-linux-android/bin/ld: the vtable symbol may be undefined because the class is missing its key function
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/home/wangqiang/cpprest/obj/local/x86/bingrequest] Error 1
I search the statement "GetCurrentThreadId" in Release folder, the result is:
include/pplx/pplxlinux.h:            auto id = ::pplx::details::platform::GetCurrentThreadId();
include/pplx/pplxlinux.h:            _ASSERTE(_M_owner == ::pplx::details::platform::GetCurrentThreadId());
include/pplx/pplxwin.h:        _PPLXIMP long __cdecl GetCurrentThreadId();
include/pplx/pplxwin.h:            auto id = ::pplx::details::platform::GetCurrentThreadId();
include/pplx/pplxwin.h:            _ASSERTE(_M_owner == ::pplx::details::platform::GetCurrentThreadId());
include/pplx/pplxcancellation_token.h:            long tid = ::pplx::details::platform::GetCurrentThreadId();
include/pplx/pplxcancellation_token.h:                        if (tid == ::pplx::details::platform::GetCurrentThreadId())
src/pplx/pplxlinux.cpp:        _PPLXIMP long GetCurrentThreadId()
src/pplx/pplxwin.cpp:        _PPLXIMP long __cdecl GetCurrentThreadId()
src/pplx/pplxwin.cpp:            return (long)(::GetCurrentThreadId());
src/pplx/pplxapple.cpp:        _PPLXIMP long GetCurrentThreadId()
Then i look into the coppers.a, but there is no implement in it:
wangqiang@ubuntu:~/casablanca/Build_android/build/build.x86.debug/Binaries$ ar -t libcpprest.a
fileio_posix.cpp.o
json.cpp.o
json_parsing.cpp.o
json_serialization.cpp.o
asyncrt_utils.cpp.o
web_utilities.cpp.o
pplx.cpp.o
threadpool.cpp.o
uri.cpp.o
uri_builder.cpp.o
uri_parser.cpp.o
http_msg.cpp.o
http_helpers.cpp.o
http_client_msg.cpp.o
http_client_asio.cpp.o
x509_cert_utilities.cpp.o
http_server_asio.cpp.o
http_listener.cpp.o
http_listener_msg.cpp.o
http_server_api.cpp.o
oauth1.cpp.o
oauth2.cpp.o
ws_msg.cpp.o
ws_client.cpp.o
ws_client_wspp.cpp.o
base64.cpp.o
x509_cert_utilities_android.cpp.o
You can check the file src/CMakeLists.txt, there is no implement on android indeed.
if(UNIX)
  set(SOURCES
    streams/fileio_posix.cpp
    json/json.cpp
    json/json_parsing.cpp
    json/json_serialization.cpp
    utilities/asyncrt_utils.cpp
    utilities/web_utilities.cpp
    pplx/pplx.cpp
    pplx/threadpool.cpp
    uri/uri.cpp
    uri/uri_builder.cpp
    uri/uri_parser.cpp
    http/common/http_msg.cpp
    http/common/http_helpers.cpp
    http/client/http_client_msg.cpp
    http/client/http_client_asio.cpp
    http/client/x509_cert_utilities.cpp
    http/listener/http_server_asio.cpp
    http/listener/http_listener.cpp
    http/listener/http_listener_msg.cpp
    http/listener/http_server_api.cpp
    http/oauth/oauth1.cpp
    http/oauth/oauth2.cpp
    websockets/client/ws_msg.cpp
    websockets/client/ws_client.cpp
    websockets/client/ws_client_wspp.cpp
    utilities/base64.cpp
    )
  if(APPLE)
    set(SOURCES ${SOURCES} 
      pplx/pplxapple.cpp
      http/client/x509_cert_utilities_apple.cpp
      )
    find_library(COREFOUNDATION CoreFoundation "/")
    find_library(SECURITY Security "/")
    set(EXTRALINKS ${COREFOUNDATION} ${SECURITY})
  elseif(ANDROID)                           #no implement in this condition
    set(SOURCES $(SOURCES) http/client/x509_cert_utilities_android.cpp)
  else()
    set(SOURCES ${SOURCES} pplx/pplxlinux.cpp)
  endif()
endif()
I think the same problem will occur when build armeabi version on android
BTW, i can clone the source code from the respository:https://git01.codeplex.com/casablanca on windows
but it fails on both linux and os x
Coordinator
Jan 14, 2015 at 4:34 PM
Hi wangqiang,

It looks like the source file, pplx/pplxlinux.cpp, containing the function definitions is accidentally not being included on Android. Can you edit the CMakeLists.txt file at line 42 to also include pplx/pplxlinux.cpp. It should look like the following:
  elseif(ANDROID)
    set(SOURCES ${SOURCES} pplx/pplxlinux.cpp)
    set(SOURCES ${SOURCES} http/client/x509_cert_utilities_android.cpp)
  else()
    set(SOURCES ${SOURCES} pplx/pplxlinux.cpp)
  endif()
Does it work then?
Thanks,
Steve
Coordinator
Jan 21, 2015 at 8:22 PM
Hi wangqiang,

You never replied back, but the pplxlinux.cpp source file has been added to the CMakeLists.txt file when targeting Android. This change has been made in the development branch.

Steve
Jan 22, 2015 at 6:35 AM
Edited Jan 22, 2015 at 7:56 AM
Hi, stevetgates, sorry for late reply. It works now, thank you very much!