title: Could not link static c library with shared lib in android using Cmake
body: <p>I have been trying linking prebuilt static library with shared library using CMake.txt.</p>
  
  <p>Following is my Cmake.txt</p>
  
  <pre><code>add_library( # Specifies the name of the library.
           native-lib
  
           # Sets the library as a shared library.
           SHARED
  
           # Provides a relative path to your source file(s).
           src/main/cpp/native-lib.c )
  
  
           # Specifies a path to native header files.
          include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/)
          add_library(my_test_lib STATIC IMPORTED)
          set_target_properties(my_test_lib PROPERTIES IMPORTED_LOCATION  ${CMAKE_SOURCE_DIR}/src/main/jni/libmytestlib.a)
          target_link_libraries(native-lib my_test_lib)
  </code></pre>
  
  <p>I have put <strong>libmytestlib.a</strong> in src/main/jni location.</p>
  
  <p>I am calling <strong>addnumbers()</strong> function from <strong>native-lib.c(shared lib)</strong>. 
  function has definition in static library.</p>
  
  <p>Every time i built the program it gives me error</p>
  
  <pre><code>[2/2] Linking C shared library ..\..\..\..\build\intermediates\cmake\debug\obj\x86\libnative-lib.so
  FAILED: cmd.exe /C "cd . &amp;&amp; C:\Users\Rajeev\AppData\Local\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe  --target=i686-none-linux-android --gcc-toolchain=C:/Users/Rajeev/AppData/Local/Android/sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/windows-x86_64 --sysroot=C:/Users/Rajeev/AppData/Local/Android/sdk/ndk-bundle/sysroot -fPIC -isystem 
   C:/Users/Rajeev/AppData/Local/Android/sdk/ndk-bundle/sysroot/usr/include/i686-linux-android -D__ANDROID_API__=18 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -Wa,--noexecstack -Wformat -Werror=format-security  -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a --sysroot C:/Users/Rajeev/AppData/Local/Android/sdk/ndk-bundle/platforms/android-18/arch-x86 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libnative-lib.so -o ..\..\..\..\build\intermediates\cmake\debug\obj\x86\libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.c.o  ../../../../src/main/jni/libmytestlib.a -lm &amp;&amp; cd ."
   C:/Users/Rajeev/AppData/Local/Android/sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/windows-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: error: ../../../../src/main/jni/libmytestlib.a(mytestlib.o): incompatible target
  
  D:\Projects\Android_Projects\YegoMotoDriverBikeLoginPassIntg\app\src\main\cpp/native-lib.c:37: error: undefined reference to 'addnumbers'
  
  clang.exe: error: linker command failed with exit code 1 (use -v to see invocation)
  
   ninja: build stopped: subcommand failed.
  </code></pre>
  
  <p>Why it is giving <strong>Incompatible target</strong> error every time.. I have searched through stackoverflow but no solution worked.. Please guide ...</p>
  
  <p><strong>Edit</strong></p>
  
  <p><strong>NOTE - Static library libmytestlib.a is pre-built on LINUX machine</strong> </p>