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

编译执行结果

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

相关推荐
鹏程十八少2 小时前
3. Android 腾讯开源的 Shadow,凭什么成为插件化“终极方案”?
android·前端·面试
TheNextByte12 小时前
如何通过蓝牙将联系人从Android传输到 iPhone
android·cocoa·iphone
Wpa.wk2 小时前
性能测试-性能监控相关命令-基础篇
android·linux·运维·经验分享·测试工具·性能测试·性能监控
Kapaseker2 小时前
必须要搞懂的 View 核心问题
android·kotlin
运筹vivo@2 小时前
攻防世界: simple_php
android·php·android studio
2501_915921432 小时前
360移动端性能监控实践QDAS-APM(iOS篇)
android·macos·ios·小程序·uni-app·cocoa·iphone
CDwenhuohuo2 小时前
uniapp 安卓原生截图保存到相册跟api服务器 canvas实现 plus.nativeObj.Bitmap实现
android·uni-app
感觉不怎么会2 小时前
Android 4.4 - APN类型扩展(一)
android·开发语言·python
云诗卡达12 小时前
Flutter安卓APP接入极光推送和本地通知
android·flutter