I installed android sdk, platform and build tools and NDK in my ArchLinux to develop with android-studio and c++. I've created a simple "hello world program" just to start but it is not compiling. The error message on build returned by android studio is "A problem occurred configuring project ':app'. executing external native build for cmake /home/fabio/AndroidStudioProjects/HelloWorld/app/CMakeLists.txt"
On the CMakeError.log:
Determining if the C compiler works failed with the following output:
Change Dir: /home/fabio/AndroidStudioProjects/HelloWorld/app/.externalNativeBuild/cmake/debug/armeabi/CMakeFiles/CMakeTmp
Run Build Command:"/opt/android-sdk/cmake/3.6.3155560/bin/ninja" "cmTC_be251"
[1/2] Building C object CMakeFiles/cmTC_be251.dir/testCCompiler.c.o
FAILED: /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -target armv5te-none-linux-androideabi -gcc-toolchain /opt/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot=/opt/android-ndk/platforms/android-15/arch-arm -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -fno-integrated-as -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -fno-integrated-as -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -o CMakeFiles/cmTC_be251.dir/testCCompiler.c.o -c /home/fabio/AndroidStudioProjects/HelloWorld/app/.externalNativeBuild/cmake/debug/armeabi/CMakeFiles/CMakeTmp/testCCompiler.c
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directoryninja: build stopped: subcommand failed.
For the creation of the project, I just checked the option "Include c++ support" and started with a blank activity, changed no code then.
Edit Tryied instlalling libtinfo as suggested in this thread but didn't worked.
I experienced the same issue. Quite many of the other distributions often have outdated packages. They still use ncurses 5 instead of ncurses 6 (libtinfo seems to belong to ncurses). Assuming, that the android ndk's version of clang was built on such a system, it was worth a try to use ncurses 5. From the Arch User Repositories I was able to install the latest version of ncurses5-compat-libs (and I also installed the 32bit version: lib32-ncurses5-compat-libs). This solved the problem for me. If you have it installed already, try reinstalling or updating it, if it is outdated.
Related
I am trying to integrate native (C++) OpenCV code into my project. I am following this project on github. After I click refresh linked C++ projects the compiler exits with exit code 1.
2:48 AM Gradle sync finished in 3 s 67 ms
2:48 AM C/C++ Configuration Problem
native-lib | debug | x86
Compiler exited with error code 1: /home/user/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -xc++ --target=i686-none-linux-android24 --gcc-toolchain=/home/user/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/home/user/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Dnative_lib_EXPORTS -isystem /home/user/Downloads/forLinux/android studio/opencv-4.3.0-android-sdk/OpenCV-android-sdk/sdk/native/jni/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -O0 -fno-limit-debug-info -fPIC -std=gnu++11 -fpch-preprocess -v -dD -E
Android (5900059 based on r365631c) clang version 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 207d7abc1a2abf3ef8d4301736d6a7ebc224a290) (based on LLVM 9.0.8svn)
Target: i686-none-linux-android24
Thread model: posix
Dir: /home/user/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin
Found candidate GCC installation: /home/user/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/i686-linux-android/4.9.x
Found candidate GCC installation: /home/user/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/x86_64-linux-android/4.9.x
Selected GCC installation: /home/user/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/i686-linux-android/4.9.x Candidate multilib: .;#m32
Selected multilib: .;#m32 clang++: error: no such file or directory: 'studio/opencv-4.3.0-android-sdk/OpenCV-android-sdk/sdk/native/jni/include'
The folder containing open-cv sdk had a space in its name. Removing the space solved the error.
today I installed android studio 3.2.1 on my windows 10 PC at home.
(I have installed a previous version 3 months ago but I unstalled it before installing new one, because it had similar problem I remember)
When I install the program, it is supposed to build itself but it fails with below messages.
Run Build Command:"C:/Users/Chan
Kim/AppData/Local/Android/Sdk/cmake/3.6.4111459/bin/ninja.exe" "cmTC_4535f"
[1/2] Building C object CMakeFiles/cmTC_4535f.dir/testCCompiler.c.o
FAILED:
C:\Users\CHANKI~1\AppData\Local\Android\Sdk\NDK-BU~1\TOOLCH~1\llvm\prebuilt\WINDOW~1\bin\clang.exe
--target=armv7-none-linux-androideabi24 --gcc-toolchain="C:/Users/Chan
Kim/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64"
--sysroot="C:/Users/Chan Kim/AppData/Local/Android/Sdk/ndk-bundle/sysroot"
-isystem C:/Users/Chan
Kim/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong
-no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
-mthumb -mfpu=neon -Wa,--noexecstack -Wformat -Werror=format-security -fPIE
-o CMakeFiles/cmTC_4535f.dir/testCCompiler.c.o -c
C:\ANDPRG\app\.externalNativeBuild\cmake\release\armeabi-v7a\CMakeFiles\CMakeTmp\testCCompiler.c
error: no such file or directory:
'Kim/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:/ANDPRG/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeOutput.log".
See also "C:/ANDPRG/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeError.log".
Build command failed.
Error while executing process C:\Users\Chan Kim\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\ANDPRG\app -BC:\ANDPRG\app\.externalNativeBuild\cmake\debug\armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-24 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\ANDPRG\app\build\intermediates\cmake\debug\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=C:\Users\Chan Kim\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_CXX_FLAGS= -DCMAKE_TOOLCHAIN_FILE=C:\Users\Chan Kim\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\Users\Chan Kim\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}
-- Check for working C compiler: C:/Users/Chan Kim/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Users/Chan Kim/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:/ANDPRG/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeTmp
Run Build Command:"C:/Users/Chan
Kim/AppData/Local/Android/Sdk/cmake/3.6.4111459/bin/ninja.exe" "cmTC_23398"
[1/2] Building C object CMakeFiles/cmTC_23398.dir/testCCompiler.c.o
FAILED:
C:\Users\CHANKI~1\AppData\Local\Android\Sdk\NDK-BU~1\TOOLCH~1\llvm\prebuilt\WINDOW~1\bin\clang.exe
--target=armv7-none-linux-androideabi24 --gcc-toolchain="C:/Users/Chan
Kim/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64"
--sysroot="C:/Users/Chan Kim/AppData/Local/Android/Sdk/ndk-bundle/sysroot"
-isystem C:/Users/Chan
Kim/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong
-no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
-mthumb -mfpu=neon -Wa,--noexecstack -Wformat -Werror=format-security -fPIE
-o CMakeFiles/cmTC_23398.dir/testCCompiler.c.o -c
C:\ANDPRG\app\.externalNativeBuild\cmake\debug\armeabi-v7a\CMakeFiles\CMakeTmp\testCCompiler.c
error: no such file or directory:
'Kim/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:/ANDPRG/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeOutput.log".
See also "C:/ANDPRG/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeError.log".
I saw similar question on SO but it's not exactly same to my situtation and I tried the suggestions(Refresh linked C++ project) and it didn't work. and some advices are for linux. The first error message is 'can't find cCompilerProgram.c' for cmake.(When I look into the folder, the file is not actuall there) How can I solve this? By the way, my login name on windows 10 is 'Chan Kim' with space in the middle. Can it have any problem? I guess the testCCompiler.c file is what the build process make during the build.
Any suggestion will be deeply appreciated.
the error actually reads:
-- Check for working C compiler: .../prebuilt/windows-x86_64/bin/clang.exe -- broken
this seems related.
My problem was that my login name in windows10 was 'Chan Kim' and the error log shows it cannot parse down the folder name containing 'Chan Kim' and it cannot process space in the folder name. So I created a new account 'ckim' and did the same (it downloads huge amount of data under C:\Users\ckim this time) and everything works fine.
So DON'T USE USERNAME WITH SPACE whne using android studio. (I don't know why the book and android studio doesn't warn about this situtation. I read in the book, if my login name contains Korean characters, it won't work. but it turns out login name with space doesn't work either).
Hope this be useful for someone.
ADD : I tried configuring the SDK again using Users\ChanKim\AppData folder and it works too. (originally it was using Users\Chan Kim\AppData)
I am trying to build an android native project using gradle. While the build passes for the architectures arm64-v8a, x86 and x86_64, it fails for armeabi-v7a with a unique error:
/{sdk-path}/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -D__ANDROID_API__=15 -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 -frtti -fexceptions -Os -DNDEBUG -O2 -DNDEBUG -D_NDEBUG=1 -s -fPIC -Wdeprecated-declarations -std=c++14 -MD -MT CMakeFiles/acplocalnet.dir/src/main/cpp/HttpTransferCallbackHookImpl.cpp.o -MF CMakeFiles/acplocalnet.dir/src/main/cpp/HttpTransferCallbackHookImpl.cpp.o.d -o CMakeFiles/acplocalnet.dir/src/main/cpp/HttpTransferCallbackHookImpl.cpp.o -c /Users/acpl/workspace/ACPLocal_net_Android/net/project/android/acplocalnet/app/src/main/cpp/HttpTransferCallbackHookImpl.cpp
clang++: warning: argument unused during compilation: '-s' [-Wunused-command-line-argument]
error: unable to open output file '/apps/temp/HttpTransferCallbackHookImpl-baaa5e.s': 'No such file or directory'
1 error generated.
ninja: build stopped: subcommand failed.
The issue here is I am able to run this command and it builds the native libraries successfully when run the machine locally, but it fails when it is run through jenkins. The other amusing thing is that it fails only for the abi armeabi-v7a and passes for all other architectures.
I have verified the user, path and environment variables like ANDROID_HOME and ANDROID_NDK_HOME which are same when I run using the command line on the machine locally and when run using jenkins.
The command was not able to open the output files in the location "/apps/temp" as this directory was not present in the slave. This temp directory present in the jenkins master and was passed to the slave which was visible in the build variable TMP_DIR. Explicitly mentioning a valid temporary directory for the jenkins slave fixed the issue.
I cloned a project from a github repository and opened it in my Android Studio 3.0.
As soon as I open up Android Studio I get an Error:
Cannot load module file 'C:\Users\David Ferrara\AndroidStudioProjects\ClBooking-master\Bookingtest.iml':
File C:\Users\David Ferrara\AndroidStudioProjects\ClBooking-master\Bookingtest.iml does not exist
Would you like to remove module 'Bookingtest' from the project?
I don't understand why a file doesn't exist when I cloned the project right from the github.
Another Error that come up with the Gradle Sync is and External Native Build Issue.
External Native Build Issues
Build command failed.
Error while executing process C:\Users\David Ferrara\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\David Ferrara\AndroidStudioProjects\ClBooking-master\app -BC:\Users\David Ferrara\AndroidStudioProjects\ClBooking-master\app\.externalNativeBuild\cmake\release\armeabi -DANDROID_ABI=armeabi -DANDROID_PLATFORM=android-16 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\David Ferrara\AndroidStudioProjects\ClBooking-master\app\build\intermediates\cmake\release\obj\armeabi -DCMAKE_BUILD_TYPE=Release -DANDROID_NDK=C:\Users\David Ferrara\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_TOOLCHAIN_FILE=C:\Users\David Ferrara\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\Users\David Ferrara\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}
-- Check for working C compiler: C:/Users/David Ferrara/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Users/David Ferrara/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/David Ferrara/AndroidStudioProjects/ClBooking-master/app/.externalNativeBuild/cmake/release/armeabi/CMakeFiles/CMakeTmp
Run Build Command:"C:/Users/David
Ferrara/AppData/Local/Android/Sdk/cmake/3.6.4111459/bin/ninja.exe"
"cmTC_93f60"
[1/2] Building C object CMakeFiles/cmTC_93f60.dir/testCCompiler.c.o
FAILED:
C:\Users\DAVIDF~1\AppData\Local\Android\Sdk\NDK-BU~1\TOOLCH~1\llvm\prebuilt\WINDOW~1\bin\clang.exe
--target=armv5te-none-linux-androideabi --gcc-toolchain="C:/Users/David
Ferrara/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64"
--sysroot="C:/Users/David
Ferrara/AppData/Local/Android/Sdk/ndk-bundle/sysroot" -isystem
C:/Users/David
Ferrara/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=16 -g -DANDROID -ffunction-sections -funwind-tables
-fstack-protector-strong -no-canonical-prefixes -march=armv5te
-mtune=xscale -msoft-float -fno-integrated-as -mthumb -Wa,--noexecstack
-Wformat -Werror=format-security -fPIE -o
CMakeFiles/cmTC_93f60.dir/testCCompiler.c.o -c "C:\Users\David
Ferrara\AndroidStudioProjects\ClBooking-master\app\.externalNativeBuild\cmake\release\armeabi\CMakeFiles\CMakeTmp\testCCompiler.c"
Error:Error:error: no such file or directory:
'Ferrara/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/David Ferrara/AndroidStudioProjects/ClBooking-master/app/.externalNativeBuild/cmake/release/armeabi/CMakeFiles/CMakeOutput.log".
See also "C:/Users/David Ferrara/AndroidStudioProjects/ClBooking-master/app/.externalNativeBuild/cmake/release/armeabi/CMakeFiles/CMakeError.log".
Build command failed.
Error while executing process C:\Users\David Ferrara\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\David Ferrara\AndroidStudioProjects\ClBooking-master\app -BC:\Users\David Ferrara\AndroidStudioProjects\ClBooking-master\app\.externalNativeBuild\cmake\debug\armeabi -DANDROID_ABI=armeabi -DANDROID_PLATFORM=android-16 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\David Ferrara\AndroidStudioProjects\ClBooking-master\app\build\intermediates\cmake\debug\obj\armeabi -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=C:\Users\David Ferrara\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_TOOLCHAIN_FILE=C:\Users\David Ferrara\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\Users\David Ferrara\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}
-- Check for working C compiler: C:/Users/David Ferrara/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Users/David Ferrara/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/David Ferrara/AndroidStudioProjects/ClBooking-master/app/.externalNativeBuild/cmake/debug/armeabi/CMakeFiles/CMakeTmp
Run Build Command:"C:/Users/David
Ferrara/AppData/Local/Android/Sdk/cmake/3.6.4111459/bin/ninja.exe"
"cmTC_17c6b"
[1/2] Building C object CMakeFiles/cmTC_17c6b.dir/testCCompiler.c.o
FAILED:
C:\Users\DAVIDF~1\AppData\Local\Android\Sdk\NDK-BU~1\TOOLCH~1\llvm\prebuilt\WINDOW~1\bin\clang.exe
--target=armv5te-none-linux-androideabi --gcc-toolchain="C:/Users/David
Ferrara/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64"
--sysroot="C:/Users/David
Ferrara/AppData/Local/Android/Sdk/ndk-bundle/sysroot" -isystem
C:/Users/David
Ferrara/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=16 -g -DANDROID -ffunction-sections -funwind-tables
-fstack-protector-strong -no-canonical-prefixes -march=armv5te
-mtune=xscale -msoft-float -fno-integrated-as -mthumb -Wa,--noexecstack
-Wformat -Werror=format-security -fPIE -o
CMakeFiles/cmTC_17c6b.dir/testCCompiler.c.o -c "C:\Users\David
Ferrara\AndroidStudioProjects\ClBooking-master\app\.externalNativeBuild\cmake\debug\armeabi\CMakeFiles\CMakeTmp\testCCompiler.c"
Error:Error:error: no such file or directory:
'Ferrara/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/David Ferrara/AndroidStudioProjects/ClBooking-master/app/.externalNativeBuild/cmake/debug/armeabi/CMakeFiles/CMakeOutput.log".
See also "C:/Users/David Ferrara/AndroidStudioProjects/ClBooking-master/app/.externalNativeBuild/cmake/debug/armeabi/CMakeFiles/CMakeError.log".
C:\Users\David Ferrara\AppData\Local\Android\Sdk\cmake\3.6.4111459\share\cmake-3.6\Modules\CMakeTestCCompiler.cmake
Error:Error:line (61)/Users/David Ferrara/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe" is not able to compile a simple test program.
Open File
Error:Error:line (61)/Users/David Ferrara/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe" is not able to compile a simple test program.
Open File
I've tired to search for answers on this subject and have come across some answers that are similar to my question except they are not solutions for my specific question.
I'm stuck at a wall and don't know what to do to resolve this Error. All I want to do is clone a repo from github and work on the project in Android studio. All of my SDKs are installed.
This may be caused by the space in the folder C:/Users/David Ferrara/AppData/Local/
If so, it is likely a bug in Android Studio, CMake, or ninja
How might one run an NDK Cmake build independently from the rest of an Android project, ideally from the command line, external to Android Studio?
The equivalent of running ndk-build from the jni directory for slightly older Android NDK projects.
I need to investigate exactly what the calls to the compiler look like, and I can't seem to get this information when building the whole project from within Android Studio
My first attempt was just to run cmake from the project/app directory containing CMakeLists.txt, but this informs me that cmake is not installed - so how is Android Studio managing to build it then?
If your goal is to just run from the command line (as opposed to trying to do exactly what gradle is doing), just use cmake the way you normally would:
$ cmake -DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=whatever $YOUR_SOURCE_DIR
Alternatively, you can just run ./gradlew from the command line.
Your original problem is that you cannot see the command-line invocation when building with Android Studio.
You can get the command line arguments to the compiler by editing your app/build.gradle file.
defaultConfig {
...
externalNativeBuild {
cmake {
...
arguments "-DCMAKE_VERBOSE_MAKEFILE=1", ...
}
}
}
In Adroid Studio's Gradle Console pane, you will then see the command line for the compiler and linker like so:
[1/176] /home/bram/android-sdk-linux/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7-none-linux-androideabi --gcc-toolchain=/home/bram/android-sdk-linux/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot=/home/bram/android-sdk-linux/ndk-bundle/sysroot -isystem /home/bram/android-sdk-linux/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -D__ANDROID_API__=19 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-integrated-as -marm -mfpu=neon -Wa,--noexecstack -Wformat -Werror=format-security -Os -DNDEBUG -fPIC -MD -MT /home/bram/src/GPGOAP/CMakeFiles/gpgoap.dir/astar.c.o -MF /home/bram/src/GPGOAP/CMakeFiles/gpgoap.dir/astar.c.o.d -o /home/bram/src/GPGOAP/CMakeFiles/gpgoap.dir/astar.c.o -c /home/bram/src/GPGOAP/astar.c
As detail to the accepted answer:
The complete set of parameters passed to CMake is written to:
<project-root>/<module-root>/.externalNativeBuild/cmake/<build-type>/<ABI>/cmake_build_command.txt`
See for details: https://developer.android.com/ndk/guides/cmake.html#build-command