I have a library (C++) using tbb on both Windows and Linux. Now I need to port it to Android. For that I use vs 2015 and create an android shared object there. Most of my C++ sources ported ok and I can run them in a small demo app on my Android phone, however I have problems with tbb. Here is what I tried:
1. I tried to find a pre-compiled tbb (libtbb.so and libttbb_debug.so) but I could not find. That should be the easiest way!
2. I tried to compile from source on a linux box (Mint 17.3 64 bit with gcc 5.x installed), where I put the android ndk (latest). I run this command:
ndk-build target=android tbb arch=arm
All compiles ok but when I try to use them I get this error while linking:
/s/ndk-toolchain/src/build/../gcc/gcc-4.9/libgcc/unwind-arm-common.inc(855): error : undefined reference to '__cxa_call_unexpected'
Thanks for any help,
The function is the C++ exception handler. The C runtime library that you are linking against is apparently not C++ (with exception handler). This is not a TBB problem.
it looks you need to add "APP_STL := gnustl_shared" line to the Application.mk file. Do you have such line?
BTW, which tbb version do you use?
Added later: also it would be good to set up follwing C++ features "APP_GNUSTL_FORCE_CPP_FEATURES := exceptions rtti". you can find a list of expected C++ keys in the tachyon example inside the package.
I think you should look at the kernel and the version . I think the version 4.5 gives problems .. is there any solution to compile version 4.5.3 or 4.5.2 HAVE A GOOD WORK
After more digging, I think I found the issue, however I still do not have a solution.
Because of the cross platform nature of my library, I decided to build it using Visual Studio 2015 by creating a native activity application (this is pure C++ with no Java, at least no Java written by the user). It looks that while MS support creating shared libraries (so), when you try to hook them up to such a project (nativeActivity project), the so is not deployed, or not deployed correctly on the Android device/emulator. However, if you use a static library (.a) you can link it correctly and all works.
My first issue regarding the linker error was because I used the IDE to add the tbb_debug.so to the project. Probably I picked up the wrong place in the IDE so I got that error. The fix was to just use 'normal' -llibtbb_debug.so. This fixes the compilation issue however when I try to run my test app on android, it fails. I suspect it is because the so tbb so is not deployed correctly.
Ok so until I (or someone else) figures out how to hook up a so library to the native activity project created with vs 2015, the solution is to build tbb as a static library. I know how to build it as a dynamic library (I did it on a linux box), but how do I build tbb as a static library?
The command I used on linux is: ndk-build target=android tbb arch=arm. How do I tell this to build a static library instead of a dynamic one?