Android studio 编译faiss

一、安装Android studio、NDK、Cmake

安装Android studio就不说了,

打开Android studio,File>Settings>Languages & Frameworks > Android SDK > SDK Tools就会出现下面这个界面,然后安装NDK和CMake;

记住这里的路径,下面所有使用cmake、ninja、ndk的地方,都使用下面路径

bash 复制代码
C:\Users\16786\AppData\Local\Android\Sdk\cmake\3.31.6\bin\cmake.exe
C:/Users/16786/AppData/Local/Android/Sdk/cmake/3.31.6/bin/ninja.exe
C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake


二、编译faiss

1、下载faiss

去github上https://github.com/facebookresearch/faiss下载faiss源码

下载之后解压

2、开始编译

bash 复制代码
cd faiss 
mkdir android_build
cd android_build

之后执行编译

bash 复制代码
C:\Users\16786\AppData\Local\Android\Sdk\cmake\3.31.6\bin\cmake.exe ..   -G Ninja   -DCMAKE_MAKE_PROGRAM=C:/Users/16786/AppData/Local/Android/Sdk/cmake/3.31.6/bin/ninja.exe  -DCMAKE_TOOLCHAIN_FILE=C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a   -DANDROID_PLATFORM=android-21   -DANDROID_STL=c++_static   -DCMAKE_BUILD_TYPE=Release   -DFAISS_OPT_LEVEL=generic   -DFAISS_ENABLE_GPU=OFF   -DFAISS_ENABLE_PYTHON=OFF   -DFAISS_ENABLE_C_API=ON   -DFAISS_ENABLE_EXTRAS=OFF   -DBUILD_TESTING=OFF   -DBUILD_SHARED_LIBS=OFF   -DFAISS_ENABLE_MKL=OFF   -DFAISS_ENABLE_LAPACK=OFF   -DFAISS_ENABLE_OPENMP=OFF -DFAISS_ENABLE_BLAS=OFF

3、报错

但是会报错,说找不到 BLAS,即使我们在编译命令里指定了FAISS_ENABLE_BLAS=OFF,也还是不行,因为faiss里默认会编译BLAS,报错如下

bash 复制代码
CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/cmake/3.31.6/share/cmake-3.31/Modules/CMakeDetermineSystem.cmake:146 (include)
  CMakeLists.txt:49 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:54 (include)
  C:/Users/16786/AppData/Local/Android/Sdk/cmake/3.31.6/share/cmake-3.31/Modules/CMakeDetermineSystem.cmake:146 (include)
  CMakeLists.txt:49 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  CMakeLists.txt:49 (project)


-- The CXX compiler identification is Clang 14.0.7
-- Detecting CXX compiler ABI info
CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-02a4df/CMakeLists.txt:2 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:54 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-02a4df/CMakeLists.txt:2 (project)


-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-5y0s9u/CMakeLists.txt:3 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:54 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-5y0s9u/CMakeLists.txt:3 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-7kblxa/CMakeLists.txt:3 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:54 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-7kblxa/CMakeLists.txt:3 (project)


-- Found OpenMP_CXX: -fopenmp=libomp (found version "5.0")
-- Found OpenMP: TRUE (found version "5.0")
-- Looking for sgemm_
CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-2mon2s/CMakeLists.txt:3 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:54 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-2mon2s/CMakeLists.txt:3 (project)


-- Looking for sgemm_ - not found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-xqfubg/CMakeLists.txt:3 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:54 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-xqfubg/CMakeLists.txt:3 (project)


-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-wxceit/CMakeLists.txt:3 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:54 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-wxceit/CMakeLists.txt:3 (project)


-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-fjz9kb/CMakeLists.txt:3 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:54 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-fjz9kb/CMakeLists.txt:3 (project)


-- Looking for pthread_create in pthread - not found
-- Check if compiler accepts -pthread
CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-upd6vk/CMakeLists.txt:3 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:54 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-upd6vk/CMakeLists.txt:3 (project)


-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
CMake Error at C:/Users/16786/AppData/Local/Android/Sdk/cmake/3.31.6/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
  Could NOT find BLAS (missing: BLAS_LIBRARIES)
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/cmake/3.31.6/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
  C:/Users/16786/AppData/Local/Android/Sdk/cmake/3.31.6/share/cmake-3.31/Modules/FindBLAS.cmake:1419 (find_package_handle_standard_args)
  faiss/CMakeLists.txt:463 (find_package)


-- Configuring incomplete, errors occurred!
PS C:\Users\16786\AndroidStudioProjects\faiss\android_build>
PS C:\Users\16786\AndroidStudioProjects\faiss\android_build>
PS C:\Users\16786\AndroidStudioProjects\faiss\android_build>
PS C:\Users\16786\AndroidStudioProjects\faiss\android_build>
PS C:\Users\16786\AndroidStudioProjects\faiss\android_build>
PS C:\Users\16786\AndroidStudioProjects\faiss\android_build>
PS C:\Users\16786\AndroidStudioProjects\faiss\android_build>
PS C:\Users\16786\AndroidStudioProjects\faiss\android_build>
PS C:\Users\16786\AndroidStudioProjects\faiss\android_build>
PS C:\Users\16786\AndroidStudioProjects\faiss\android_build>
PS C:\Users\16786\AndroidStudioProjects\faiss\android_build> C:\Users\16786\AppData\Local\Android\Sdk\cmake\3.31.6\bin\cmake.exe ..   -G Ninja   -DCMAKE_MAKE_PROGRAM=C:/Users/16786/AppData/Local/Android/Sdk/cmake/3.31.6/bin/ninja.exe  -DCMAKE_TOOLCHAIN_FILE=C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a   -DANDROID_PLATFORM=android-21   -DANDROID_STL=c++_static   -DCMAKE_BUILD_TYPE=Release   -DFAISS_OPT_LEVEL=generic   -DFAISS_ENABLE_GPU=OFF   -DFAISS_ENABLE_PYTHON=OFF   -DFAISS_ENABLE_C_API=ON   -DFAISS_ENABLE_EXTRAS=OFF   -DBUILD_TESTING=OFF   -DBUILD_SHARED_LIBS=OFF   -DFAISS_ENABLE_MKL=OFF   -DFAISS_ENABLE_LAPACK=OFF   -DFAISS_ENABLE_OPENMP=OFF -DFAISS_ENABLE_BLAS=OFF
CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/cmake/3.31.6/share/cmake-3.31/Modules/CMakeDetermineSystem.cmake:146 (include)
  CMakeLists.txt:49 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:54 (include)
  C:/Users/16786/AppData/Local/Android/Sdk/cmake/3.31.6/share/cmake-3.31/Modules/CMakeDetermineSystem.cmake:146 (include)
  CMakeLists.txt:49 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  CMakeLists.txt:49 (project)


-- The CXX compiler identification is Clang 14.0.7
-- Detecting CXX compiler ABI info
CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-cgmhgv/CMakeLists.txt:2 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:54 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-cgmhgv/CMakeLists.txt:2 (project)


-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-av3nl8/CMakeLists.txt:3 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:54 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-av3nl8/CMakeLists.txt:3 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-l7ow5i/CMakeLists.txt:3 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:54 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-l7ow5i/CMakeLists.txt:3 (project)


-- Found OpenMP_CXX: -fopenmp=libomp (found version "5.0")
-- Found OpenMP: TRUE (found version "5.0")
-- Looking for sgemm_
CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-wej3hv/CMakeLists.txt:3 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:54 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-wej3hv/CMakeLists.txt:3 (project)


-- Looking for sgemm_ - not found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-8pye0y/CMakeLists.txt:3 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:54 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-8pye0y/CMakeLists.txt:3 (project)


-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-llt4j7/CMakeLists.txt:3 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:54 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-llt4j7/CMakeLists.txt:3 (project)


-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-1rvskr/CMakeLists.txt:3 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:54 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-1rvskr/CMakeLists.txt:3 (project)


-- Looking for pthread_create in pthread - not found
-- Check if compiler accepts -pthread
CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-7hlsgz/CMakeLists.txt:3 (project)


CMake Deprecation Warning at C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake:54 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/3.31.6/CMakeSystem.cmake:6 (include)
  C:/Users/16786/AndroidStudioProjects/faiss/android_build/CMakeFiles/CMakeScratch/TryCompile-7hlsgz/CMakeLists.txt:3 (project)


-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
CMake Error at C:/Users/16786/AppData/Local/Android/Sdk/cmake/3.31.6/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
  Could NOT find BLAS (missing: BLAS_LIBRARIES)
Call Stack (most recent call first):
  C:/Users/16786/AppData/Local/Android/Sdk/cmake/3.31.6/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
  C:/Users/16786/AppData/Local/Android/Sdk/cmake/3.31.6/share/cmake-3.31/Modules/FindBLAS.cmake:1419 (find_package_handle_standard_args)
  C:/Users/16786/AppData/Local/Android/Sdk/cmake/3.31.6/share/cmake-3.31/Modules/FindLAPACK.cmake:247 (find_package)
  C:/Users/16786/AppData/Local/Android/Sdk/cmake/3.31.6/share/cmake-3.31/Modules/FindLAPACK.cmake:283 (_lapack_find_dependency)
  faiss/CMakeLists.txt:476 (find_package)


-- Configuring incomplete, errors occurred!

4、解决方法

我们需要修改faiss/CMakeLists.txt,注意是faiss下的faiss里的CMakeLists![

找到457行开始

将457-476行替换成下面

bash 复制代码
if(MKL_FOUND)
  target_link_libraries(faiss PRIVATE ${MKL_LIBRARIES})
  target_link_libraries(faiss_avx2 PRIVATE ${MKL_LIBRARIES})
  target_link_libraries(faiss_avx512 PRIVATE ${MKL_LIBRARIES})
  target_link_libraries(faiss_avx512_spr PRIVATE ${MKL_LIBRARIES})
else()
  if(NOT ANDROID AND FAISS_ENABLE_BLAS)
    find_package(BLAS REQUIRED)
    target_link_libraries(faiss PRIVATE ${BLAS_LIBRARIES})
  endif()

  if(NOT ANDROID AND FAISS_ENABLE_LAPACK)
    find_package(LAPACK REQUIRED)
    target_link_libraries(faiss PRIVATE ${LAPACK_LIBRARIES})
  endif()
endif()

改之前

改之后

之后执行编译命令,就正常了

5、编译结果

之后执行

bash 复制代码
C:\Users\16786\AppData\Local\Android\Sdk\cmake\3.31.6\bin\cmake.exe --build . --parallel

编译执行结果

这是静态链接,若需动态链接,更改编译命令即可

相关推荐
BoomHe1 天前
Android AOSP13 原生 Launcher3 壁纸获取方式
android
Digitally1 天前
如何将联系人从 Android 转移到 Android
android
李小枫1 天前
webflux接收application/x-www-form-urlencoded参数
android·java·开发语言
爱丽_1 天前
MySQL `EXPLAIN`:看懂执行计划、判断索引是否生效与排错套路
android·数据库·mysql
NPE~1 天前
[App逆向]环境搭建下篇 — — 逆向源码+hook实战
android·javascript·python·教程·逆向·hook·逆向分析
yewq-cn1 天前
AOSP 下载
android
cch89181 天前
Laravel vs ThinkPHP:PHP框架终极对决
android·php·laravel
米码收割机1 天前
【Android】基于安卓app的汽车租赁管理系统(源码+部署方式+论文)[独一无二]
android·汽车
流星雨在线1 天前
安卓使用 Startup 管理三方 SDK 初始化
android·startup
jwn9991 天前
Laravel3.x:PHP框架的经典里程碑
android