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

编译执行结果

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

相关推荐
ANYOUZHEN7 小时前
bugku shell
android
南宫码农10 小时前
我的电视 - Android原生电视直播软件 完整使用教程
android·开发语言·windows·电视盒子
道亦无名10 小时前
音频数据特征值提取 方法和步骤
android·音视频
Lancker11 小时前
定制侠 一个国产纯血鸿蒙APP的诞生过程
android·华为·智能手机·鸿蒙·国产操作系统·纯血鸿蒙·华为鸿蒙
2601_9498095912 小时前
flutter_for_openharmony家庭相册app实战+通知设置实现
android·javascript·flutter
液态不合群13 小时前
【面试题】MySQL 中 count(*)、count(1) 和 count(字段名) 有什么区别?
android·数据库·mysql
雪球Snowball14 小时前
【Android关键流程】资源加载
android
2501_9159184114 小时前
常见 iOS 抓包工具的使用,从代理抓包、设备抓包到数据流抓包
android·ios·小程序·https·uni-app·iphone·webview
墨月白16 小时前
[QT]QProcess的相关使用
android·开发语言·qt
enbug17 小时前
编译安卓内核:以坚果R1、魔趣MK100(Android 10)系统为例
android·linux