You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Title says it all. If hnswlib is included in multiple source files, we observe linking errors like:
CMakeFiles/libtest.dir/src/find_nearest_neighbors.cpp.o: In function `cpuid(int*, int, int)':
/home/luna/Code/knncolle/build/_deps/hnswlib-src/./hnswlib/hnswlib.h:29: multiple definition of `cpuid(int*, int, int)'
CMakeFiles/libtest.dir/src/Hnsw.cpp.o:/home/luna/Code/knncolle/build/_deps/hnswlib-src/./hnswlib/hnswlib.h:29: first defined here
CMakeFiles/libtest.dir/src/find_nearest_neighbors.cpp.o: In function `xgetbv(unsigned int)':
/home/luna/Code/knncolle/build/_deps/hnswlib-src/./hnswlib/hnswlib.h:32: multiple definition of `xgetbv(unsigned int)'
CMakeFiles/libtest.dir/src/Hnsw.cpp.o:/home/luna/Code/knncolle/build/_deps/hnswlib-src/./hnswlib/hnswlib.h:32: first defined here
CMakeFiles/libtest.dir/src/find_nearest_neighbors.cpp.o: In function `AVXCapable()':
/home/luna/Code/knncolle/build/_deps/hnswlib-src/./hnswlib/hnswlib.h:54: multiple definition of `AVXCapable()'
CMakeFiles/libtest.dir/src/Hnsw.cpp.o:/home/luna/Code/knncolle/build/_deps/hnswlib-src/./hnswlib/hnswlib.h:54: first defined here
CMakeFiles/libtest.dir/src/find_nearest_neighbors.cpp.o: In function `AVX512Capable()':
/home/luna/Code/knncolle/build/_deps/hnswlib-src/./hnswlib/hnswlib.h:81: multiple definition of `AVX512Capable()'
etc.
I believe this should be easily fixed by adding an inline at the start of every function's definition, e.g.
Oh, great. I only ever pull from your master in my builds, so I didn't see that. Would be great to get #383 in there.
Interesting that the PR uses static to resolve ODR issues, as opposed to inline. I'd speculate that inline would yield smaller binaries because static forces each translation unit to have its own local copy of the function. But I don't really know. Probably doesn't matter.
Title says it all. If
hnswlib
is included in multiple source files, we observe linking errors like:I believe this should be easily fixed by adding an
inline
at the start of every function's definition, e.g.This includes all the
DISTFUNC
-based functions in thespace_*.h
headers.The text was updated successfully, but these errors were encountered: