I'm trying to build the c/c++ file "libtensorflow_inference.so" in gradle through cmake by manually adding CMakeLists.txt. I have already installed Cmake but the following error occurs on building gradle(I have also provided the CMakeLists.txt content and program structure):
External Native Build Issues
Build command failed.
Error while executing process C:\Users\Mujtaba Faizi\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\Mujtaba Faizi\Documents\Git\BasicAI\BasicAI\app -BC:\Users\Mujtaba Faizi\Documents\Git\BasicAI\BasicAI\app\.externalNativeBuild\cmake\release\armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-21 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Mujtaba Faizi\Documents\Git\BasicAI\BasicAI\app\build\intermediates\cmake\release\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DANDROID_NDK=C:\Users\Mujtaba Faizi\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_TOOLCHAIN_FILE=C:\Users\Mujtaba Faizi\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\Users\Mujtaba Faizi\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}
-- Check for working C compiler: C:/Users/Mujtaba Faizi/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Users/Mujtaba Faizi/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken
It fails with the following output:
Change Dir: C:/Users/Mujtaba Faizi/Documents/Git/BasicAI/BasicAI/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeTmp
Run Build Command:"C:/Users/Mujtaba
Faizi/AppData/Local/Android/Sdk/cmake/3.6.4111459/bin/ninja.exe"
"cmTC_671fa"
[1/2] Building C object CMakeFiles/cmTC_671fa.dir/testCCompiler.c.o
FAILED:
C:\Users\MUJTAB~1\AppData\Local\Android\Sdk\NDK-BU~1\TOOLCH~1\llvm\prebuilt\WINDOW~1\bin\clang.exe
--target=armv7-none-linux-androideabi --gcc-toolchain="C:/Users/Mujtaba
Faizi/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64"
--sysroot="C:/Users/Mujtaba
Faizi/AppData/Local/Android/Sdk/ndk-bundle/sysroot" -isystem
C:/Users/Mujtaba
Faizi/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables
-fstack-protector-strong -no-canonical-prefixes -march=armv7-a
-mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-integrated-as -mthumb
-Wa,--noexecstack -Wformat -Werror=format-security -fPIE -o
CMakeFiles/cmTC_671fa.dir/testCCompiler.c.o -c "C:\Users\Mujtaba
Faizi\Documents\Git\BasicAI\BasicAI\app\.externalNativeBuild\cmake\release\armeabi-v7a\CMakeFiles\CMakeTmp\testCCompiler.c"
Error:error: no such file or directory:
'Faizi/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi'
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt
-- Configuring incomplete, errors occurred!
See also "C:/Users/Mujtaba Faizi/Documents/Git/BasicAI/BasicAI/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Mujtaba Faizi/Documents/Git/BasicAI/BasicAI/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeError.log".
Build command failed.
Error while executing process C:\Users\Mujtaba Faizi\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\Mujtaba Faizi\Documents\Git\BasicAI\BasicAI\app -BC:\Users\Mujtaba Faizi\Documents\Git\BasicAI\BasicAI\app\.externalNativeBuild\cmake\debug\armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-21 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Mujtaba Faizi\Documents\Git\BasicAI\BasicAI\app\build\intermediates\cmake\debug\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=C:\Users\Mujtaba Faizi\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_TOOLCHAIN_FILE=C:\Users\Mujtaba Faizi\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\Users\Mujtaba Faizi\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}
-- Check for working C compiler: C:/Users/Mujtaba Faizi/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Users/Mujtaba Faizi/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken
It fails with the following output:
Change Dir: C:/Users/Mujtaba Faizi/Documents/Git/BasicAI/BasicAI/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeTmp
Run Build Command:"C:/Users/Mujtaba
Faizi/AppData/Local/Android/Sdk/cmake/3.6.4111459/bin/ninja.exe"
"cmTC_89189"
[1/2] Building C object CMakeFiles/cmTC_89189.dir/testCCompiler.c.o
FAILED:
C:\Users\MUJTAB~1\AppData\Local\Android\Sdk\NDK-BU~1\TOOLCH~1\llvm\prebuilt\WINDOW~1\bin\clang.exe
--target=armv7-none-linux-androideabi --gcc-toolchain="C:/Users/Mujtaba
Faizi/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64"
--sysroot="C:/Users/Mujtaba
Faizi/AppData/Local/Android/Sdk/ndk-bundle/sysroot" -isystem
C:/Users/Mujtaba
Faizi/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables
-fstack-protector-strong -no-canonical-prefixes -march=armv7-a
-mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-integrated-as -mthumb
-Wa,--noexecstack -Wformat -Werror=format-security -fPIE -o
CMakeFiles/cmTC_89189.dir/testCCompiler.c.o -c "C:\Users\Mujtaba
Faizi\Documents\Git\BasicAI\BasicAI\app\.externalNativeBuild\cmake\debug\armeabi-v7a\CMakeFiles\CMakeTmp\testCCompiler.c"
Error:error: no such file or directory:
'Faizi/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi'
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt
-- Configuring incomplete, errors occurred!
See also "C:/Users/Mujtaba Faizi/Documents/Git/BasicAI/BasicAI/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Mujtaba Faizi/Documents/Git/BasicAI/BasicAI/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeError.log".
C:\Users\Mujtaba Faizi\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake
Warning:(63, 98) (include) CMakeLists.txt
Warning:(63, 98) (include) CMakeLists.txt
C:\Users\Mujtaba Faizi\AppData\Local\Android\Sdk\cmake\3.6.4111459\share\cmake-3.6\Modules\CMakeTestCCompiler.cmake
Error:(61, 0) /Users/Mujtaba Faizi/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe" is not able to compile a simple test program.
<a href="openFile:C:\Users\Mujtaba Faizi\AppData\Local\Android\Sdk\cmake\3.6.4111459\share\cmake-3.6\Modules\CMakeTestCCompiler.cmake">Open File</a>
Error:(61, 0) /Users/Mujtaba Faizi/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe" is not able to compile a simple test program.
<a href="openFile:C:\Users\Mujtaba Faizi\AppData\Local\Android\Sdk\cmake\3.6.4111459\share\cmake-3.6\Modules\CMakeTestCCompiler.cmake">Open File</a>
This is my project structure CMakeLists.txt:
# Sets the minimum version of CMake required to build your native library.
# This ensures that a certain set of CMake features is available to
# your build.
cmake_minimum_required(VERSION 3.4.1)
# Specifies a library name, specifies whether the library is STATIC or
# SHARED, and provides relative paths to the source code. You can
# define multiple libraries by adding multiple add_library() commands,
# and CMake builds them for you. When you build your app, Gradle
# automatically packages shared libraries with your APK.
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.cpp )
# Specifies a path to native header files.
include_directories(src/main/cpp/armeabi-v7a/libtensorflow_inference.so)
Thanks in advance.