SPTAG
SPTAG copied to clipboard
build failure due to missing mutex include
When building SPTAG git master with GCC 11 on Debian bookworm, there is a build failure when compiling SPTAG because std::unique_lock doesn't exist due to a missing #include <mutex> in the AnnService/inc/Core/Common/BKTree.h file. There are a number of other situations in the code where #include <mutex> is also missing.
c++ -DBOOST_ALL_NO_LIB -DBOOST_SYSTEM_DYN_LINK -I"AnnService" -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Wall -Wunreachable-code -Wno-reorder -Wno-sign-compare -Wno-unknown-pragmas -Wcast-align -lm -lrt -fopenmp -fopenmp -std=gnu++14 -MD -MT AnnService/CMakeFiles/sptag-indexbuilder.dir/src/IndexBuilder/main.cpp.o -MF CMakeFiles/sptag-indexbuilder.dir/src/IndexBuilder/main.cpp.o.d -o CMakeFiles/sptag-indexbuilder.dir/src/IndexBuilder/main.cpp.o -c "AnnService/src/IndexBuilder/main.cpp"
In file included from AnnService/inc/SSDServing/SelectHead_BKT/AnalyzeTree.h:9,
from AnnService/src/SSDServing/SelectHead_BKT/AnalyzeTree.cpp:4:
AnnService/inc/Core/Common/BKTree.h: In member function 'void SPTAG::COMMON::BKTree::Rebuild(const SPTAG::COMMON::Dataset<T>&, SPTAG::DistCalcMethod, SPTAG::IAbortOperation*)':
AnnService/inc/Core/Common/BKTree.h:409:22: error: 'unique_lock' is not a member of 'std'
409 | std::unique_lock<std::shared_timed_mutex> lock(*m_lock);
| ^~~~~~~~~~~
In file included from AnnService/inc/SSDServing/SelectHead_BKT/AnalyzeTree.h:9,
from AnnService/src/SSDServing/SelectHead_BKT/AnalyzeTree.cpp:4:
AnnService/inc/Core/Common/BKTree.h:19:1: note: 'std::unique_lock' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
18 | #include "DistanceUtils.h"
+++ |+#include <mutex>
19 |
In file included from AnnService/inc/SSDServing/SelectHead_BKT/AnalyzeTree.h:9,
from AnnService/src/SSDServing/SelectHead_BKT/AnalyzeTree.cpp:4:
AnnService/inc/Core/Common/BKTree.h:409:57: error: expected primary-expression before '>' token
409 | std::unique_lock<std::shared_timed_mutex> lock(*m_lock);
| ^
AnnService/inc/Core/Common/BKTree.h:409:59: error: there are no arguments to 'lock' that depend on a template parameter, so a declaration of 'lock' must be available [-fpermissive]
409 | std::unique_lock<std::shared_timed_mutex> lock(*m_lock);
| ^~~~
AnnService/inc/Core/Common/BKTree.h:409:59: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
.../SPTAG (master=) for f in `git grep -l unique_lock ` ; do if ! grep -q '<mutex>' $f ; then echo $f ; fi ; done
AnnService/inc/Core/Common/BKTree.h
AnnService/inc/Core/Common/KDTree.h
AnnService/inc/Helper/ConcurrentSet.h
AnnService/src/Client/ClientWrapper.cpp
AnnService/src/Core/BKT/BKTIndex.cpp
AnnService/src/Core/KDT/KDTIndex.cpp
AnnService/src/Core/MetadataSet.cpp
AnnService/src/Helper/Concurrent.cpp
fwiw, this is causing the SPTAG build to fail for ann-benchmarks. It'd be nice to have SPTAG included in the April 2023 benchmarks.
@ankane if you need a patch for this issue, there is one in the missing-includes branch of my fork. I use this patch (and other ones) to help build the Debian package of SPTAG.
-- bye, pabs
https://bonedaddy.net/pabs3/
Great, thanks @pabs3! Working great: https://github.com/erikbern/ann-benchmarks/pull/370
error: ‘unique_lock’ is not a member of ‘std’
I have this error when building SPTAG
The missing-includes branch in my fork fixes this, basically it adds #include <mutex> to every file that uses std::unique_lock.
@pabs3 I tried your forck and now it gives me this error:
error: ‘fail’ is not a member of ‘SPTAG::ErrorCode’; did you mean ‘Fail’?
Probably some other patches are required too, try the debian branch, it contains all the patches that go into the Debian sptag package.