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

编译执行结果

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

相关推荐
我命由我123455 小时前
Android 开发问题:获取到的 Android ID 发生了变化
android·java·开发语言·java-ee·android studio·android jetpack·android runtime
恋猫de小郭5 小时前
由于 iOS 26 的键盘变化,Flutter 又要重构键盘区域逻辑
android·前端·flutter
我命由我123455 小时前
Android 开发问题:Unable to find explicit activity class
android·java·java-ee·android studio·android jetpack·android-studio·android runtime
我命由我123455 小时前
Android 开发问题:全局的主题颜色设置,导致 CheckBox 控件在勾选状态下不显示样式
android·java·开发语言·java-ee·intellij-idea·intellij idea·android jetpack
Kapaseker5 小时前
一个丝滑的数字计数器,讲清楚 AnimatedContent 怎么用
android·kotlin
故渊at5 小时前
第十六板块:Android 综合实战与架构复盘 | 第三十七篇:从开机到桌面点击的全链路架构复盘
android·架构·冷启动·热启动·架构复盘·开机到桌面
私人珍藏库5 小时前
[Android] 红妆相机-拍照美颜图片美化工具
android·数码相机·app·软件·多功能
唯刻V5 小时前
你的IDE已经不认识你了
android·ide·android-studio·cli
zhangphil6 小时前
Android OS系统kswapd、kworker、HeapTaskDaemon/heapdamon对卡顿丢帧及应用流畅性的影响
android
海天一色y6 小时前
深入理解 RAG 技术:从语义张量到向量数据库,Milvus 与 FAISS 全面对比
数据库·milvus·faiss