solrex/caffe-mobile

Errors in building for android: <stdio.h> not found and openBlas failed to compile

Opened this issue · 6 comments

I get the following errors when trying to run ./tools/build_android.sh
The main error seems to be <stdio.h> not found. I followed the procedure mentioned in README. I have all the dependencies installed.
$NDK_HOME is set correctly:

echo $NDK_HOME 
/home/sid/Android/Sdk/ndk-bundle
#####################
 Building OpenBLAS for Android
#####################

OpenBLAS: Detecting fortran compiler failed. Cannot compile LAPACK. Only compile BLAS.
make[1]: warning: -jN forced in submake: disabling jobserver mode.
make[1]: Entering directory '/home/sid/caffe-mobile/third_party/OpenBLAS-0.2.19/interface'
/home/sid/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/home/sid/Android/Sdk/ndk-bundle/platforms/android-16/arch-arm -O2 -DMAX_STACK_ALLOC=2048 -Wall -DF_INTERFACE_GFORT -fPIC -DNO_LAPACK -DNO_LAPACKE -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=4 -marm -march=armv5 -DASMNAME=saxpy -DASMFNAME=saxpy_ -DNAME=saxpy_ -DCNAME=saxpy -DCHAR_NAME=\"saxpy_\" -DCHAR_CNAME=\"saxpy\" -DNO_AFFINITY -I.. -I. -UDOUBLE  -UCOMPLEX -c axpy.c -o saxpy.o
/home/sid/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/home/sid/Android/Sdk/ndk-bundle/platforms/android-16/arch-arm -O2 -DMAX_STACK_ALLOC=2048 -Wall -DF_INTERFACE_GFORT -fPIC -DNO_LAPACK -DNO_LAPACKE -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=4 -marm -march=armv5 -DASMNAME=sswap -DASMFNAME=sswap_ -DNAME=sswap_ -DCNAME=sswap -DCHAR_NAME=\"sswap_\" -DCHAR_CNAME=\"sswap\" -DNO_AFFINITY -I.. -I. -UDOUBLE  -UCOMPLEX -c swap.c -o sswap.o
/home/sid/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/home/sid/Android/Sdk/ndk-bundle/platforms/android-16/arch-arm -O2 -DMAX_STACK_ALLOC=2048 -Wall -DF_INTERFACE_GFORT -fPIC -DNO_LAPACK -DNO_LAPACKE -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=4 -marm -march=armv5 -DASMNAME=scopy -DASMFNAME=scopy_ -DNAME=scopy_ -DCNAME=scopy -DCHAR_NAME=\"scopy_\" -DCHAR_CNAME=\"scopy\" -DNO_AFFINITY -I.. -I. -UDOUBLE  -UCOMPLEX -c copy.c -o scopy.o
/home/sid/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/home/sid/Android/Sdk/ndk-bundle/platforms/android-16/arch-arm -O2 -DMAX_STACK_ALLOC=2048 -Wall -DF_INTERFACE_GFORT -fPIC -DNO_LAPACK -DNO_LAPACKE -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=4 -marm -march=armv5 -DASMNAME=sscal -DASMFNAME=sscal_ -DNAME=sscal_ -DCNAME=sscal -DCHAR_NAME=\"sscal_\" -DCHAR_CNAME=\"sscal\" -DNO_AFFINITY -I.. -I. -UDOUBLE  -UCOMPLEX -c scal.c -o sscal.o
swap.c:39:19: fatal error: stdio.h: No such file or directory
 #include <stdio.h>
                   ^
compilation terminated.
Makefile:795: recipe for target 'sswap.o' failed
make[1]: *** [sswap.o] Error 1
make[1]: *** Waiting for unfinished jobs....
copy.c:39:19: fatal error: stdio.h: No such file or directory
 #include <stdio.h>
                   ^
compilation terminated.
scal.c:39:19: fatal error: stdio.h: No such file or directory
 #include <stdio.h>
                   ^
compilation terminated.
Makefile:750: recipe for target 'sscal.o' failed
make[1]: *** [sscal.o] Error 1
Makefile:777: recipe for target 'scopy.o' failed
make[1]: *** [scopy.o] Error 1
axpy.c:39:19: fatal error: stdio.h: No such file or directory
 #include <stdio.h>
                   ^
compilation terminated.
Makefile:723: recipe for target 'saxpy.o' failed
make[1]: *** [saxpy.o] Error 1
make[1]: Leaving directory '/home/sid/caffe-mobile/third_party/OpenBLAS-0.2.19/interface'
Makefile:126: recipe for target 'libs' failed
make: *** [libs] Error 1
getarch_2nd.c: In function ‘main’:
getarch_2nd.c:12:35: error: ‘SGEMM_DEFAULT_UNROLL_M’ undeclared (first use in this function); did you mean ‘XGEMM_DEFAULT_UNROLL_M’?
     printf("SGEMM_UNROLL_M=%d\n", SGEMM_DEFAULT_UNROLL_M);
                                   ^~~~~~~~~~~~~~~~~~~~~~
                                   XGEMM_DEFAULT_UNROLL_M
getarch_2nd.c:12:35: note: each undeclared identifier is reported only once for each function it appears in
getarch_2nd.c:13:35: error: ‘SGEMM_DEFAULT_UNROLL_N’ undeclared (first use in this function); did you mean ‘SGEMM_DEFAULT_UNROLL_M’?
     printf("SGEMM_UNROLL_N=%d\n", SGEMM_DEFAULT_UNROLL_N);
                                   ^~~~~~~~~~~~~~~~~~~~~~
                                   SGEMM_DEFAULT_UNROLL_M
getarch_2nd.c:14:35: error: ‘DGEMM_DEFAULT_UNROLL_M’ undeclared (first use in this function); did you mean ‘SGEMM_DEFAULT_UNROLL_M’?
     printf("DGEMM_UNROLL_M=%d\n", DGEMM_DEFAULT_UNROLL_M);
                                   ^~~~~~~~~~~~~~~~~~~~~~
                                   SGEMM_DEFAULT_UNROLL_M
getarch_2nd.c:15:35: error: ‘DGEMM_DEFAULT_UNROLL_N’ undeclared (first use in this function); did you mean ‘DGEMM_DEFAULT_UNROLL_M’?
     printf("DGEMM_UNROLL_N=%d\n", DGEMM_DEFAULT_UNROLL_N);
                                   ^~~~~~~~~~~~~~~~~~~~~~
                                   DGEMM_DEFAULT_UNROLL_M
getarch_2nd.c:19:35: error: ‘CGEMM_DEFAULT_UNROLL_M’ undeclared (first use in this function); did you mean ‘DGEMM_DEFAULT_UNROLL_M’?
     printf("CGEMM_UNROLL_M=%d\n", CGEMM_DEFAULT_UNROLL_M);
                                   ^~~~~~~~~~~~~~~~~~~~~~
                                   DGEMM_DEFAULT_UNROLL_M
getarch_2nd.c:20:35: error: ‘CGEMM_DEFAULT_UNROLL_N’ undeclared (first use in this function); did you mean ‘CGEMM_DEFAULT_UNROLL_M’?
     printf("CGEMM_UNROLL_N=%d\n", CGEMM_DEFAULT_UNROLL_N);
                                   ^~~~~~~~~~~~~~~~~~~~~~
                                   CGEMM_DEFAULT_UNROLL_M
getarch_2nd.c:21:35: error: ‘ZGEMM_DEFAULT_UNROLL_M’ undeclared (first use in this function); did you mean ‘CGEMM_DEFAULT_UNROLL_M’?
     printf("ZGEMM_UNROLL_M=%d\n", ZGEMM_DEFAULT_UNROLL_M);
                                   ^~~~~~~~~~~~~~~~~~~~~~
                                   CGEMM_DEFAULT_UNROLL_M
getarch_2nd.c:22:35: error: ‘ZGEMM_DEFAULT_UNROLL_N’ undeclared (first use in this function); did you mean ‘ZGEMM_DEFAULT_UNROLL_M’?
     printf("ZGEMM_UNROLL_N=%d\n", ZGEMM_DEFAULT_UNROLL_N);
                                   ^~~~~~~~~~~~~~~~~~~~~~
                                   ZGEMM_DEFAULT_UNROLL_M
getarch_2nd.c:69:50: error: ‘SGEMM_DEFAULT_Q’ undeclared (first use in this function); did you mean ‘SGEMM_DEFAULT_UNROLL_N’?
     printf("#define SLOCAL_BUFFER_SIZE\t%ld\n", (SGEMM_DEFAULT_Q * SGEMM_DEFAULT_UNROLL_N * 4 * 1 *  sizeof(float)));
                                                  ^~~~~~~~~~~~~~~
                                                  SGEMM_DEFAULT_UNROLL_N
getarch_2nd.c:70:50: error: ‘DGEMM_DEFAULT_Q’ undeclared (first use in this function); did you mean ‘SGEMM_DEFAULT_Q’?
     printf("#define DLOCAL_BUFFER_SIZE\t%ld\n", (DGEMM_DEFAULT_Q * DGEMM_DEFAULT_UNROLL_N * 2 * 1 *  sizeof(double)));
                                                  ^~~~~~~~~~~~~~~
                                                  SGEMM_DEFAULT_Q
getarch_2nd.c:71:50: error: ‘CGEMM_DEFAULT_Q’ undeclared (first use in this function); did you mean ‘DGEMM_DEFAULT_Q’?
     printf("#define CLOCAL_BUFFER_SIZE\t%ld\n", (CGEMM_DEFAULT_Q * CGEMM_DEFAULT_UNROLL_N * 4 * 2 *  sizeof(float)));
                                                  ^~~~~~~~~~~~~~~
                                                  DGEMM_DEFAULT_Q
getarch_2nd.c:72:50: error: ‘ZGEMM_DEFAULT_Q’ undeclared (first use in this function); did you mean ‘CGEMM_DEFAULT_Q’?
     printf("#define ZLOCAL_BUFFER_SIZE\t%ld\n", (ZGEMM_DEFAULT_Q * ZGEMM_DEFAULT_UNROLL_N * 2 * 2 *  sizeof(double)));
                                                  ^~~~~~~~~~~~~~~
                                                  CGEMM_DEFAULT_Q
make: *** [getarch_2nd] Error 1
make -j 4 -f Makefile.install install
make[1]: Entering directory '/home/sid/caffe-mobile/third_party/OpenBLAS-0.2.19'
Makefile.install:20: *** OpenBLAS: Please run "make" firstly.  Stop.
make[1]: Leaving directory '/home/sid/caffe-mobile/third_party/OpenBLAS-0.2.19'
Makefile:309: recipe for target 'install' failed
make: *** [install] Error 2
mkdir: cannot create directory ‘../build_armeabi’: File exists
CMake Warning at third_party/android-cmake/android.toolchain.cmake:324 (message):
  Could not determine machine name for compiler from
  /home/sid/Android/Sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/linux-x86_64
Call Stack (most recent call first):
  third_party/android-cmake/android.toolchain.cmake:551 (__DETECT_TOOLCHAIN_MACHINE_NAME)
  third_party/android-cmake/android.toolchain.cmake:608 (__GLOB_NDK_TOOLCHAINS)
  /usr/share/cmake-3.10/Modules/CMakeDetermineSystem.cmake:91 (include)
  CMakeLists.txt


CMake Warning at third_party/android-cmake/android.toolchain.cmake:324 (message):
  Could not determine machine name for compiler from
  /home/sid/Android/Sdk/ndk-bundle/toolchains/mipsel-linux-android-4.9/prebuilt/linux-x86_64
Call Stack (most recent call first):
  third_party/android-cmake/android.toolchain.cmake:551 (__DETECT_TOOLCHAIN_MACHINE_NAME)
  third_party/android-cmake/android.toolchain.cmake:608 (__GLOB_NDK_TOOLCHAINS)
  /usr/share/cmake-3.10/Modules/CMakeDetermineSystem.cmake:91 (include)
  CMakeLists.txt


CMake Error at third_party/android-cmake/android.toolchain.cmake:309 (file):
  file STRINGS file
  "/home/sid/Android/Sdk/ndk-bundle/platforms/android-16/arch-arm/usr/include/android/api-level.h"
  cannot be read.
Call Stack (most recent call first):
  third_party/android-cmake/android.toolchain.cmake:821 (__DETECT_NATIVE_API_LEVEL)
  /usr/share/cmake-3.10/Modules/CMakeDetermineSystem.cmake:91 (include)
  CMakeLists.txt


CMake Error at third_party/android-cmake/android.toolchain.cmake:823 (message):
  Specified Android API level (16) does not match to the level found ().
  Probably your copy of NDK is broken.
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/CMakeDetermineSystem.cmake:91 (include)
  CMakeLists.txt


ERRORCould not find libsupc++.a for a chosen platform. Either your NDK is not supported or is broken.
CMake Deprecation Warning at /usr/share/cmake-3.10/Modules/CMakeForceCompiler.cmake:69 (message):
  The CMAKE_FORCE_C_COMPILER macro is deprecated.  Instead just set
  CMAKE_C_COMPILER and allow CMake to identify the compiler.
Call Stack (most recent call first):
  third_party/android-cmake/android.toolchain.cmake:1146 (CMAKE_FORCE_C_COMPILER)
  /usr/share/cmake-3.10/Modules/CMakeDetermineSystem.cmake:91 (include)
  CMakeLists.txt


CMake Deprecation Warning at /usr/share/cmake-3.10/Modules/CMakeForceCompiler.cmake:83 (message):
  The CMAKE_FORCE_CXX_COMPILER macro is deprecated.  Instead just set
  CMAKE_CXX_COMPILER and allow CMake to identify the compiler.
Call Stack (most recent call first):
  third_party/android-cmake/android.toolchain.cmake:1158 (CMAKE_FORCE_CXX_COMPILER)
  /usr/share/cmake-3.10/Modules/CMakeDetermineSystem.cmake:91 (include)
  CMakeLists.txt


CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
-- Configuring incomplete, errors occurred!

@Siddhant24 I guess it's the NDK version problem. NDK version r16 (and later) changed a lot of things. Adding some special arguments or changing it to r15 could solve the problem. I'll re-check this problem and find a way to fix it.

@solrex I also posted this issue on stackoverflow. Some suggestions in the comments.
https://stackoverflow.com/questions/50777571/building-openblas-for-android

@solrex @zchrissirhcz
Using NDK version r15 resolved openBLAS build problem. Now I get the following errors:


CMake Deprecation Warning at /usr/share/cmake-3.10/Modules/CMakeForceCompiler.cmake:69 (message):
  The CMAKE_FORCE_C_COMPILER macro is deprecated.  Instead just set
  CMAKE_C_COMPILER and allow CMake to identify the compiler.
Call Stack (most recent call first):
  /home/sid/caffe-mobile/third_party/android-cmake/android.toolchain.cmake:1146 (CMAKE_FORCE_C_COMPILER)
  /usr/share/cmake-3.10/Modules/CMakeDetermineSystem.cmake:91 (include)
  CMakeLists.txt:12 (project)


CMake Deprecation Warning at /usr/share/cmake-3.10/Modules/CMakeForceCompiler.cmake:83 (message):
  The CMAKE_FORCE_CXX_COMPILER macro is deprecated.  Instead just set
  CMAKE_CXX_COMPILER and allow CMake to identify the compiler.
Call Stack (most recent call first):
  /home/sid/caffe-mobile/third_party/android-cmake/android.toolchain.cmake:1158 (CMAKE_FORCE_CXX_COMPILER)
  /usr/share/cmake-3.10/Modules/CMakeDetermineSystem.cmake:91 (include)
  CMakeLists.txt:12 (project)


CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
-- Configuring incomplete, errors occurred!
See also "/home/sid/caffe-mobile/third_party/protobuf-3.1.0/.cbuild/CMakeFiles/CMakeOutput.log".

CMakeOutput.log has the following contents:

The target system is: Android - 1 - armv5te
The host system is: Linux - 4.15.0-22-generic - x86_64

@Siddhant24 Do you have "make" installed? Try "which make".

@solrex Yes I have "make" installed.
"which make" returns usr/bin/make

@Siddhant24
after hours of checking here and there,
i finally found the solution to the problem,
downgrade/upgrade cmake to 3.7.2