How to fix or locat the problem of "ninja: build stopped: subcommand failed."?

wizdzz picture wizdzz · Jun 14, 2019 · Viewed 13.2k times · Source

BACKGROUND: I want to use Obfuscator-llvm-8.0 version of clang and clang++ with AndroidStudio on Windows7; so i get the Obfuscator-llvm-8.0 source code and compile it with success, then I put "clang.exe, clang++.exe, clang-check.exe, clang-format.exe" to the original ndk toolchains, which is "xxx\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin"; if you build apk now, you will get "Build command failed." because some .h file need copy too, so i copyed them;

TROUBLE SITUATION: Build apk again, will report error(see below); so i just copy the "clang++ complie str" and execute it on windows terminal directly, it executes successfully and generated th .o file, and even i copy the cmake arguments and execute it i get the .so file;

TROUBLE: I can not build it on the Android Studio IDE, and i can not get any detail error message to fix it; Is there anything i missed? Or there anyway to find detail message about "ninja: build stopped: subcommand failed."?

I have tried search "ninja: build stopped: subcommand failed." on google, and just get some information about complie the AndroidOs, and just tell you do something to fix it but not tell you why.

Here is the full error message:

Build command failed.
Error while executing process D:\Android\Sdk\cmake\3.10.2.4988404\bin\cmake.exe with arguments {--build C:\Users\Administrator\AndroidStudioProjects\OllvmTest\app\.externalNativeBuild\cmake\debug\armeabi-v7a --target native-lib}
[1/2] Building CXX object CMakeFiles/native-lib.dir/native-lib.cpp.o
FAILED: CMakeFiles/native-lib.dir/native-lib.cpp.o 
D:\Android\Sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=armv7-none-linux-androideabi19 --gcc-toolchain=D:/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=D:/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/sysroot  -Dnative_lib_EXPORTS  -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -march=armv7-a -mthumb -Wa,--noexecstack -Wformat -Werror=format-security   -O0 -fno-limit-debug-info  -fPIC -MD -MT CMakeFiles/native-lib.dir/native-lib.cpp.o -MF CMakeFiles\native-lib.dir\native-lib.cpp.o.d -o CMakeFiles/native-lib.dir/native-lib.cpp.o -c C:/Users/Administrator/AndroidStudioProjects/OllvmTest/app/src/main/cpp/native-lib.cpp
ninja: build stopped: subcommand failed.

Answer

Angelo Dureghello picture Angelo Dureghello · Oct 28, 2020

I had this issue building in Yocto. Solution was to decrease number of threads used for the parallel build.