yahoojapan / NGT

Nearest Neighbor Search with Neighborhood Graph and Tree for High-dimensional Data
Apache License 2.0
1.22k stars 112 forks source link

Linking issue #134

Closed vishalsaraswat247 closed 1 year ago

vishalsaraswat247 commented 1 year ago

Is anyone else running into this linking issue? I was running into some other(but similar) issue when I was trying to use this library but then I tried building the sample code to check and ran into this similar issue.

instance1:~/ngt/NGT$ g++ -std=c++11 -o construct -lngt construct.cpp In file included from /usr/local/include/NGT/ObjectSpace.h:19, from /usr/local/include/NGT/ObjectSpaceRepository.h:21, from /usr/local/include/NGT/Node.h:21, from /usr/local/include/NGT/Tree.h:21, from /usr/local/include/NGT/Index.h:33, from construct.cpp:2: /usr/local/include/NGT/PrimitiveComparator.h:22:2: warning: #warning " SIMD is NOT available! " [-Wcpp] 22 | #warning " SIMD is NOT available! " | ^~~

/usr/bin/ld: /tmp/ccOnG8Mu.o: in function NGT::Index::open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)': construct.cpp:(.text._ZN3NGT5Index4openERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb[_ZN3NGT5Index4openERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb]+0x2e): undefined reference toNGT::Index::open(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, bool, bool)' /usr/bin/ld: /tmp/ccOnG8Mu.o: in function `NGT::Index::createGraphAndTree(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, NGT::Property&, bool)': construct.cpp:(.text._ZN3NGT5Index18createGraphAndTreeERKNSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_8PropertyEb[_ZN3NGT5Index18createGraphAndTreeERKNSt7cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_8PropertyEb]+0x6c): undefined reference to `NGT::Index::createGraphAndTree(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, NGT::Property&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, unsigned long, bool)' collect2: error: ld returned 1 exit status

I did try to check the code some more around the "open" issue. I do see that "open" in the header(Index.h) file but I'm not sure why it's not getting resolved. Just wondering if someone has fixed it already?

vishalsaraswat247 commented 1 year ago

Just for reference, in case anyone else runs into it. It's all about the simple ordering issue. We need to load the library before the compilation of the code, that's what's mentioned in g++ manual as well. :)

instance1:~/code/ngt/NGT$ g++ -std=c++11 -o construct construct.cpp -lngt

Maybe we could edit the command on the C++ quick start page as this doesn't occur immediately.

https://github.com/yahoojapan/NGT/wiki/Cpp-Quick-Start

masajiro commented 1 year ago

Thank you for your feedback. I updated the command you mentioned.