1

我想在 macOS 上构建 caffe2。

build caffe2 一切正常,但是当我 build android 时,使用caffe2/scripts/build_android.sh处理是到 100% 然后发生:

CMake Error at /usr/local/Cellar/cmake/3.10.1/share/cmake/Modules/CheckCXXSourceCompiles.cmake:97 (try_compile):
Failed to configure test project build system.
Call Stack (most recent call first):
  cmake/MiscCheck.cmake:34 (CHECK_CXX_SOURCE_COMPILES)
  CMakeLists.txt:61 (include)

我的 cmake 版本是:

cmake version 3.10.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

所有日志是:

```

CMake Error at third_party/android-cmake/android.toolchain.cmake:310 (file):
file STRINGS file
"/Users/zhouhuacong/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/usr/include/android/api-level.h"
cannot be read.
Call Stack (most recent call first):
third_party/android-cmake/android.toolchain.cmake:814 (__DETECT_NATIVE_API_LEVEL)
/usr/local/Cellar/cmake/3.10.1/share/cmake/Modules/CMakeDetermineSystem.cmake:94 (include)
CMakeLists.txt:6 (project)


CMake Error at third_party/android-cmake/android.toolchain.cmake:816 (message):
Specified Android API level (21) does not match to the level found ().
Probably your copy of NDK is broken.
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.10.1/share/cmake/Modules/CMakeDetermineSystem.cmake:94 (include)
CMakeLists.txt:6 (project)


CMake Deprecation Warning at /usr/local/Cellar/cmake/3.10.1/share/cmake/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:1139 (CMAKE_FORCE_C_COMPILER)
/usr/local/Cellar/cmake/3.10.1/share/cmake/Modules/CMakeDetermineSystem.cmake:94 (include)
CMakeLists.txt:6 (project)


CMake Deprecation Warning at /usr/local/Cellar/cmake/3.10.1/share/cmake/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:1151 (CMAKE_FORCE_CXX_COMPILER)
/usr/local/Cellar/cmake/3.10.1/share/cmake/Modules/CMakeDetermineSystem.cmake:94 (include)
CMakeLists.txt:6 (project)


-- Performing Test CAFFE2_LONG_IS_INT32_OR_64
CMake Error at /Users/zhouhuacong/CaffeProject/caffe2/third_party/android-cmake/android.toolchain.cmake:310 (file):
file STRINGS file
"/Users/zhouhuacong/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/usr/include/android/api-level.h"
cannot be read.
Call Stack (most recent call first):
/Users/zhouhuacong/CaffeProject/caffe2/third_party/android-cmake/android.toolchain.cmake:814 (__DETECT_NATIVE_API_LEVEL)
/Users/zhouhuacong/CaffeProject/caffe2/build_android/CMakeFiles/3.10.1/CMakeSystem.cmake:6 (include)
/Users/zhouhuacong/CaffeProject/caffe2/build_android/CMakeFiles/CMakeTmp/CMakeLists.txt:3 (project)


CMake Error at /Users/zhouhuacong/CaffeProject/caffe2/third_party/android-cmake/android.toolchain.cmake:816 (message):
Specified Android API level (21) does not match to the level found ().
Probably your copy of NDK is broken.
Call Stack (most recent call first):
/Users/zhouhuacong/CaffeProject/caffe2/build_android/CMakeFiles/3.10.1/CMakeSystem.cmake:6 (include)
/Users/zhouhuacong/CaffeProject/caffe2/build_android/CMakeFiles/CMakeTmp/CMakeLists.txt:3 (project)


CMake Deprecation Warning at /usr/local/Cellar/cmake/3.10.1/share/cmake/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):
/Users/zhouhuacong/CaffeProject/caffe2/third_party/android-cmake/android.toolchain.cmake:1139 (CMAKE_FORCE_C_COMPILER)
/Users/zhouhuacong/CaffeProject/caffe2/build_android/CMakeFiles/3.10.1/CMakeSystem.cmake:6 (include)
/Users/zhouhuacong/CaffeProject/caffe2/build_android/CMakeFiles/CMakeTmp/CMakeLists.txt:3 (project)


CMake Deprecation Warning at /usr/local/Cellar/cmake/3.10.1/share/cmake/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):
/Users/zhouhuacong/CaffeProject/caffe2/third_party/android-cmake/android.toolchain.cmake:1151 (CMAKE_FORCE_CXX_COMPILER)
/Users/zhouhuacong/CaffeProject/caffe2/build_android/CMakeFiles/3.10.1/CMakeSystem.cmake:6 (include)
/Users/zhouhuacong/CaffeProject/caffe2/build_android/CMakeFiles/CMakeTmp/CMakeLists.txt:3 (project)


CMake Error at /usr/local/Cellar/cmake/3.10.1/share/cmake/Modules/CheckCXXSourceCompiles.cmake:97 (try_compile):
Failed to configure test project build system.
Call Stack (most recent call first):
cmake/MiscCheck.cmake:34 (CHECK_CXX_SOURCE_COMPILES)
CMakeLists.txt:61 (include)


-- Configuring incomplete, errors occurred!
See also "/Users/zhouhuacong/CaffeProject/caffe2/build_android/CMakeFiles/CMakeOutput.log".
```

我找到了第一个错误,但在我的 mac 中file STRINGS file "/Users/zhouhuacong/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/usr/include/android/api-level.h" cannot be read. 找不到该文件夹​​。include只有/Users/zhouhuacong/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/usr/lib文件夹。

这是我的 NDK 环境问题吗?我用的Android Studio 3.0,然后下载NDK 16

我哪里错了?

4

0 回答 0