Summary
Compiling Faiss using cmake on my Linux desktop produces a build error.
~/packages/faiss $ cmake -B build . -DBUILD_SHARED_LIBS=ON -DFAISS_ENABLE_C_API=ON
# [...]
~/packages/faiss $ cmake --build build -j20
# [...]
~/packages/faiss/tests/test_ivf_index.cpp:232:26: error: no matching function for call to ‘fi
nd(std::set<long unsigned int>::iterator, std::set<long unsigned int>::iterator, long unsigned int&)’
232 | std::find(
| ~~~~~~~~~^
233 | lists_probed.cbegin(),
| ~~~~~~~~~~~~~~~~~~~~~~
234 | lists_probed.cend(),
| ~~~~~~~~~~~~~~~~~~~~
235 | query_vector_listno) != lists_probed.cend())
| ~~~~~~~~~~~~~~~~~~~~
This can be solved by including set and algorithm to test_ivf_index.cpp.
Platform
OS: Arch Linux
Faiss version: e758973fa08164728eb9e136631fe6c57d7edf6c
Installed from: Attempting to compile with cmake
Faiss compilation options: -DBUILD_SHARED_LIBS=ON -DFAISS_ENABLE_C_API=ON
Running on:
Interface:
Reproduction instructions
~/packages/faiss $ cmake -B build . -DBUILD_SHARED_LIBS=ON -DFAISS_ENABLE_C_API=ON
~/packages/faiss $ cmake --build build -j20
[ 87%] Building CXX object c_api/CMakeFiles/faiss_c.dir/gpu/StandardGpuResources_c.cpp.o
In file included from /home/mfixman/packages/faiss/build/_deps/googletest-src/googletest/include/gtest/gt
est-printers.h:114,
from /home/mfixman/packages/faiss/build/_deps/googletest-src/googletest/include/gtest/gt
est-matchers.h:48,
from /home/mfixman/packages/faiss/build/_deps/googletest-src/googletest/include/gtest/in
ternal/gtest-death-test-internal.h:46,
from /home/mfixman/packages/faiss/build/_deps/googletest-src/googletest/include/gtest/gt
est-death-test.h:43,
from /home/mfixman/packages/faiss/build/_deps/googletest-src/googletest/include/gtest/gt
est.h:60,
from /home/mfixman/packages/faiss/tests/test_ivf_index.cpp:16:
/home/mfixman/packages/faiss/tests/test_ivf_index.cpp: In member function ‘virtual void IVF_list_context_
Test::TestBody()’:
/home/mfixman/packages/faiss/tests/test_ivf_index.cpp:232:26: error: no matching function for call to ‘fi
nd(std::set<long unsigned int>::iterator, std::set<long unsigned int>::iterator, long unsigned int&)’
232 | std::find(
| ~~~~~~~~~^
233 | lists_probed.cbegin(),
| ~~~~~~~~~~~~~~~~~~~~~~
234 | lists_probed.cend(),
| ~~~~~~~~~~~~~~~~~~~~
235 | query_vector_listno) != lists_probed.cend())
| ~~~~~~~~~~~~~~~~~~~~
Proposed solution
This can be fixed by adding two missing #includes to test_ivf_index.cpp.
diff --git a/tests/test_ivf_index.cpp b/tests/test_ivf_index.cpp
index 54cb7945..8e4530a9 100644
--- a/tests/test_ivf_index.cpp
+++ b/tests/test_ivf_index.cpp
@@ -12,6 +12,8 @@
#include <cstring>
#include <map>
#include <random>
+#include <set>
+#include <algorithm>
#include <gtest/gtest.h>
~/packages/faiss $ cmake --build build -j20
[ 1%] Built target swigfaiss_swig_compilation
[ 1%] Built target faiss_python_callbacks
[ 3%] Built target gtest
[ 3%] Built target gtest_main
[ 53%] Built target faiss_gpu
[ 77%] Built target faiss
[ 77%] Built target swigfaiss
[ 79%] Built target faiss_gpu_test_helper
[ 80%] Linking CXX executable TestGpuIndexBinaryFlat
[ 80%] Linking CXX executable TestGpuIndexIVFFlat
[ 80%] Linking CXX executable TestGpuIndexIVFScalarQuantizer
[ 88%] Built target faiss_c
[ 88%] Linking CXX executable TestGpuIndexFlat
[ 88%] Linking CUDA executable TestGpuDistance
[ 90%] Linking CXX executable TestGpuIndexIVFPQ
[ 90%] Linking CXX executable TestCodePacking
[ 90%] Linking CXX executable TestGpuMemoryException
[ 92%] Linking CUDA executable TestGpuSelect
[ 92%] Building CXX object tests/CMakeFiles/faiss_test.dir/test_ivf_index.cpp.o
[ 92%] Built target TestCodePacking
[ 92%] Built target TestGpuSelect
[ 92%] Built target TestGpuIndexBinaryFlat
[ 92%] Built target TestGpuMemoryException
[ 92%] Built target TestGpuIndexFlat
[ 92%] Built target TestGpuIndexIVFPQ
[ 92%] Built target TestGpuDistance
[ 92%] Built target TestGpuIndexIVFScalarQuantizer
[ 92%] Built target TestGpuIndexIVFFlat
[ 92%] Linking CXX executable faiss_test
WARNING clustering 1000 points to 40 centroids: please provide at least 1560 training points
[100%] Built target faiss_test
Summary
Compiling Faiss using cmake on my Linux desktop produces a build error.
This can be solved by including
setandalgorithmtotest_ivf_index.cpp.Platform
OS: Arch Linux
Faiss version:
e758973fa08164728eb9e136631fe6c57d7edf6cInstalled from: Attempting to compile with cmake
Faiss compilation options:
-DBUILD_SHARED_LIBS=ON -DFAISS_ENABLE_C_API=ONRunning on:
Interface:
Reproduction instructions
Proposed solution
This can be fixed by adding two missing
#includes totest_ivf_index.cpp.