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

编译执行结果

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

相关推荐
赶路人儿15 分钟前
常见的mcp配置
android·adb
阿拉斯攀登20 分钟前
【RK3576 安卓 JNI/NDK 系列 07】RK3576 实战(一):JNI 调用 GPIO 驱动点亮 LED
android studio·瑞芯微·嵌入式驱动·安卓驱动·rk3576 gpio控制
符哥200825 分钟前
充电桩 WiFi 局域网配网(Android/Kotlin)流程、指令及实例说明文档
android·开发语言·kotlin
没有了遇见1 小时前
Android 项目架构之<用户信息模块>
android
Georgewu2 小时前
如何判断应用在鸿蒙卓易通或者出境易环境下?
android·harmonyos
localbob3 小时前
Pico 4XVR 1.10.13安装包下载与安装教程 ico 4XVR最新版下载、4XVR 1.10.13 APK安装包、Pico VR看电影软件、4XVR完整版安装教程、Pico 4播放器推荐、V
android·vr·vr播放器·vr眼镜播放器下载·pico 4xvr·4xvr下载·pico 4xvr最新版安装包
峥嵘life4 小时前
Android16 EDLA【CTS】CtsConnectivityMultiDevicesTestCases存在fail项
android·学习
大傻^4 小时前
SpringAI2.0 Null Safety 实战:JSpecify 注解体系与 Kotlin 互操作
android·开发语言·人工智能·kotlin·springai
游戏开发爱好者84 小时前
React Native iOS 代码如何加密,JS 打包 和 IPA 混淆
android·javascript·react native·ios·小程序·uni-app·iphone
kcuwu.4 小时前
Python判断及循环
android·java·python