I am creating a non-trivial android library using gradle tools for building android v2.2.0 that reference a dozen ready-made .a files, the output should be a .so file. When I try to convert from ndk-build to cmake I can not properly link the .so file, because as a result of the ninja build, it seems that I could not find the headers of the static libraries.
CMakeLists.txt
cmake_minimum_required(VERSION 3.4.1) set(CMAKE_VERBOSE_MAKEFILE on) include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/prebuilt/include ) add_library(precompiledA STATIC IMPORTED) set_target_properties(precompiledA PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/prebuilt/dcmtk/lib/libprecompiledA.a) add_library(precompiledB STATIC IMPORTED) set_target_properties(precompiledB PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/prebuilt/dcmtk/lib/libprecompiledB.a) add_library(precompiledC STATIC IMPORTED) set_target_properties(precompiledC PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/prebuilt/dcmtk/lib/libprecompiledC.a) add_library( jni-library SHARED hello.cpp ) find_library( log-lib log ) target_link_libraries( jni-library precompiledA precompiledB precompiledC ${log-lib} )
build.gradle
apply plugin: 'com.android.library' android { compileSdkVersion 24 buildToolsVersion "24.0.2" defaultConfig { minSdkVersion 19 targetSdkVersion 24 ndk { abiFilters 'armeabi-v7a' } externalNativeBuild { cmake { arguments '-DANDROID_STL=gnustl_static', '-DANDROID_CPP_FEATURES=exceptions' } } } externalNativeBuild { cmake { path 'src/main/cpp/CMakeLists.txt' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) }
Error - abbreviated
ld: error: cannot find -lprecompiledA undefined references galore...
When it comes to calling gradle, .o files are generated, but during the connection, the headers associated with the static libraries seem to be missing and the connection fails. Is it possible to tell cmake where the static library headers are for reference time?
source share