0

After creating a prebuilt shared c++ library with Visual Studio 2017 i want to integrate that library into my existing android application. I compiled my shared c++ library with gcc 4.9 and i use Cmake as my build system in Android Studio.

The project itself is building and when i try deploying my .apk i get a linker error of the form

java.lang.UnsatisfiedLinkError: dlopen failed: library "ABSOLUTE PATH"

As compiler in Android Studio (defined via gradle) i tryed clang as well as the same gcc i build the library with. From my CMakeLists.txt:

add_library(libname SHARED IMPORTED) 
set_target_properties(vrcore PROPERTIES IMPORTED_LOCATION ${lib_DIR}/libname/lib/${ANDROID_ABI}/libname.so)

target_include_directories(app PRIVATE ${lib_DIR}/libname/include)

target_link_libraries(app
                  libname

I also read: How to import visual c++ library into android studio project?

And did all according to the described 'Android NDK official hello-libs CMake example': How to link a prebuilt shared Library to an Android NDK project?

And can exclude a capitalization error. Additionally i already include thirdparty shared prebuilt libraries without any problems. I hope this sketches the whole problem, if you need any additional information let me know.

SimonScholl
  • 98
  • 11
  • What value do you want to assign to `IMPORTED_LOCATION` property? Current code contains two values - `${lib_DIR}/libname` and `/lib/${ANDROID_ABI}/libname.so` - but you need to assign only one. – Tsyvarev Jan 19 '18 at 08:55
  • Sry this was my fault, they both belong together and build the relative path. ${lib_DIR}/libname/lib/${ANDROID_ABI}/libname.so – SimonScholl Jan 19 '18 at 09:06

0 Answers0