-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use milvus from another directory #254
Comments
This is a linker/loader question. For gcc toolchain, you could add Of course, you could also try to use the |
@matrixji Thanks for the reply. is that expected of build? or should all the dependencies be in the usr/local/lib directory? |
I used this bash script to include all necessary libs and include files from the cmake_dir. #!/bin/bash
CMAK_BIULD_DIR=/home/mohamed/Mohamed/HPCC/milvus-sdk-cpp/cmake_build
# Libs directories.
LIBS_DIR=$(find ${CMAK_BIULD_DIR} -type f -name '*.a' | sed -r 's|/[^/]+$||' |sort |uniq)
BUILD_LIBS_DIR=""
for DIR in $LIBS_DIR;
do BUILD_LIBS_DIR="$BUILD_LIBS_DIR -L$DIR"
done
# Libs names.
LIBS_NAMES=$(find ${CMAK_BIULD_DIR} -type f -name '*.a' -printf "%f\n")
BUILD_LIBS_NAMES=""
for NAME in $LIBS_NAMES;
do
TMP_NAME=${NAME#"lib"}
firstchar=${TMP_NAME:0:1}
if [[ $firstchar == "0" ]];then
continue
else
BUILD_LIBS_NAMES="$BUILD_LIBS_NAMES -l${TMP_NAME%".a"}"
fi
done
#Include direcotries.
INCLUDE_DIRS=$(find ${CMAK_BIULD_DIR} -type f -name '*.h' | grep include | sed 's/include.*/include/' |sort |uniq )
INCLUDE_FILES_DIR=""
for DIR in $INCLUDE_DIRS;
do INCLUDE_FILES_DIR="$INCLUDE_FILES_DIR -I$DIR"
done
#build the code.
g++ main.cpp ${INCLUDE_FILES_DIR} ${BUILD_LIBS_DIR} ${BUILD_LIBS_NAMES} -o output &> error.txt But it will be better to install the dependencies to |
Have same problem, I have both /usr/local/lib/libmilvus_sdk.a and /usr/local/include/milvus but cannot compile main.cpp, got nearly 10000 lines of undefined reference error after run: g++ -std=c++14 main.cpp -I /usr/local/include -L /usr/local/lib -l milvus_sdk -o output |
Nobody cares about this project? |
did you compile successfully under your environment? |
Yes. I followed the installation in DEVELOPMENT.md. This is what I run: git clone https://github.com/milvus-io/milvus-sdk-cpp
cd milvus-sdk-cpp
git checkout main
make all-release I checked I had both Tell me if I do something wrong? Thank you |
and is there a reason you specify to use -std=c++14? |
My OS is Ubuntu 20.04 and gcc version is 9.4.0 /usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(MilvusClientImpl.cpp.o): in function `milvus::MilvusClientImpl::CalcDistance(milvus::CalcDistanceArguments const&, milvus::DistanceArray&)::{lambda()#2}::operator()() const::{lambda(milvus::proto::milvus::VectorsArray*, std::shared_ptr<milvus::Field>&&, bool)#1}::operator()(milvus::proto::milvus::VectorsArray, std::shared_ptr<milvus::Field>, bool) const':
MilvusClientImpl.cpp:(.text+0x3a61): undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::Arena*)'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x3c10): undefined reference to `google::protobuf::RepeatedField<float>::Reserve(int)'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x3cd3): undefined reference to `google::protobuf::RepeatedField<float>::Reserve(int)'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x3d1b): undefined reference to `google::protobuf::internal::fixed_address_empty_string[abi:cxx11]'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x3e5b): undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x3e84): undefined reference to `google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::Add()'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x4000): undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x404d): undefined reference to `google::protobuf::RepeatedField<long>::Reserve(int)'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x4185): undefined reference to `google::protobuf::RepeatedField<long>::Reserve(int)'
/usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(MilvusClientImpl.cpp.o): in function `std::_Function_handler<void (milvus::proto::milvus::ShowCollectionsResponse const&), milvus::MilvusClientImpl::ShowCollections(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<milvus::CollectionInfo, std::allocator<milvus::CollectionInfo> >&)::{lambda(milvus::proto::milvus::ShowCollectionsResponse const&)#2}>::_M_invoke(std::_Any_data const&, milvus::proto::milvus::ShowCollectionsResponse const&)':
MilvusClientImpl.cpp:(.text+0x4394): undefined reference to `google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::Get(int) const'
/usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(MilvusClientImpl.cpp.o): in function `std::_Function_handler<void (milvus::proto::milvus::ShowPartitionsResponse const&), milvus::MilvusClientImpl::ShowPartitions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<milvus::PartitionInfo, std::allocator<milvus::PartitionInfo> >&)::{lambda(milvus::proto::milvus::ShowPartitionsResponse const&)#2}>::_M_invoke(std::_Any_data const&, milvus::proto::milvus::ShowPartitionsResponse const&)':
MilvusClientImpl.cpp:(.text+0x44d7): undefined reference to `google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::size() const'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x4638): undefined reference to `google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::Get(int) const'
/usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(MilvusClientImpl.cpp.o): in function `std::_Function_handler<void (milvus::proto::milvus::ListCredUsersResponse const&), milvus::MilvusClientImpl::ListCredUsers(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)::{lambda(milvus::proto::milvus::ListCredUsersResponse const&)#2}>::_M_invoke(std::_Any_data const&, milvus::proto::milvus::ListCredUsersResponse const&)':
MilvusClientImpl.cpp:(.text+0x592f): undefined reference to `google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::begin() const'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x593a): undefined reference to `google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::end() const'
/usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(MilvusClientImpl.cpp.o): in function `milvus::MilvusClientImpl::Flush(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, milvus::ProgressMonitor const&)::{lambda(milvus::proto::milvus::FlushResponse const&)#2}::operator()(milvus::proto::milvus::FlushResponse const&) const [clone .isra.0]':
MilvusClientImpl.cpp:(.text+0x5ae0): undefined reference to `google::protobuf::internal::MapFieldBase::SyncMapWithRepeatedField() const'
/usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(MilvusClientImpl.cpp.o): in function `milvus::MilvusClientImpl::Search(milvus::SearchArguments const&, milvus::SearchResults&, int)::{lambda(milvus::proto::milvus::SearchResults const&)#3}::operator()(milvus::proto::milvus::SearchResults const&) const [clone .isra.0]':
MilvusClientImpl.cpp:(.text+0x72ad): undefined reference to `google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x72bc): undefined reference to `google::protobuf::internal::LogMessage::operator<<(char const*)'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x72c7): undefined reference to `google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x72cf): undefined reference to `google::protobuf::internal::LogMessage::~LogMessage()'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x72f5): undefined reference to `google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x7304): undefined reference to `google::protobuf::internal::LogMessage::operator<<(char const*)'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x730f): undefined reference to `google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x7317): undefined reference to `google::protobuf::internal::LogMessage::~LogMessage()'
/usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(MilvusClientImpl.cpp.o): in function `std::_Function_handler<void (milvus::proto::milvus::DescribeCollectionResponse const&), milvus::MilvusClientImpl::DescribeCollection(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, milvus::CollectionDesc&)::{lambda(milvus::proto::milvus::DescribeCollectionResponse const&)#2}>::_M_invoke(std::_Any_data const&, milvus::proto::milvus::DescribeCollectionResponse const&)':
MilvusClientImpl.cpp:(.text+0x7631): undefined reference to `google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::size() const'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x766d): undefined reference to `google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::end() const'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x767d): undefined reference to `google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::begin() const'
/usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(MilvusClientImpl.cpp.o): in function `milvus::MilvusClientImpl::GetVersion(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
MilvusClientImpl.cpp:(.text+0x7c8d): undefined reference to `google::protobuf::internal::ZeroFieldsBase::~ZeroFieldsBase()'
/usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(MilvusClientImpl.cpp.o): in function `std::_Function_handler<milvus::proto::milvus::CreateCollectionRequest (), milvus::MilvusClientImpl::CreateCollection(milvus::CollectionSchema const&)::{lambda()#1}>::_M_invoke(std::_Any_data const&)':
MilvusClientImpl.cpp:(.text+0x7fcc): undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x8013): undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x803c): undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
/usr/bin/ld: MilvusClientImpl.cpp:(.text+0x80ba): undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
...
/usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(feder.pb.cc.o):(.data.rel.ro._ZTVN6milvus5proto5feder32DescribeSegmentIndexDataResponseE[_ZTVN6milvus5proto5feder32DescribeSegmentIndexDataResponseE]+0x40): undefined reference to `google::protobuf::Message::InitializationErrorString[abi:cxx11]() const'
/usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(feder.pb.cc.o):(.data.rel.ro._ZTVN6milvus5proto5feder32DescribeSegmentIndexDataResponseE[_ZTVN6milvus5proto5feder32DescribeSegmentIndexDataResponseE]+0x48): undefined reference to `google::protobuf::Message::CheckTypeAndMergeFrom(google::protobuf::MessageLite const&)'
/usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(feder.pb.cc.o):(.data.rel.ro._ZTVN6milvus5proto5feder32DescribeSegmentIndexDataResponseE[_ZTVN6milvus5proto5feder32DescribeSegmentIndexDataResponseE]+0x78): undefined reference to `google::protobuf::Message::MergeFrom(google::protobuf::Message const&)'
/usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(feder.pb.cc.o):(.data.rel.ro._ZTVN6milvus5proto5feder32DescribeSegmentIndexDataResponseE[_ZTVN6milvus5proto5feder32DescribeSegmentIndexDataResponseE]+0x80): undefined reference to `google::protobuf::Message::SpaceUsedLong() const'
/usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(feder.pb.cc.o):(.data.rel.ro+0x0): undefined reference to `google::protobuf::Message::CopyWithSourceCheck(google::protobuf::Message&, google::protobuf::Message const&)'
/usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(feder.pb.cc.o):(.data.rel.ro+0x10): undefined reference to `google::protobuf::Message::CopyWithSourceCheck(google::protobuf::Message&, google::protobuf::Message const&)'
/usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(feder.pb.cc.o):(.data.rel.ro+0x20): undefined reference to `google::protobuf::Message::CopyWithSourceCheck(google::protobuf::Message&, google::protobuf::Message const&)'
/usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(feder.pb.cc.o):(.data.rel.ro+0x30): undefined reference to `google::protobuf::Message::CopyWithSourceCheck(google::protobuf::Message&, google::protobuf::Message const&)'
/usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(feder.pb.cc.o):(.data.rel.ro+0x40): undefined reference to `google::protobuf::Message::CopyWithSourceCheck(google::protobuf::Message&, google::protobuf::Message const&)'
/usr/bin/ld: /home/longnp2/longld8/milvus-sdk-cpp/cmake_build/src/libmilvus_sdk.a(feder.pb.cc.o):(.data.rel.ro+0x50): more undefined references to `google::protobuf::Message::CopyWithSourceCheck(google::protobuf::Message&, google::protobuf::Message const&)' follow
collect2: error: ld returned 1 exit status |
IMO, this is a code integration issue, we do tests/examples with CMake, and this is smooth for application integration with milvus-sdk-cpp, but if guys use |
I installed milvus successfully and ran the simple example.
but I want to use milvus from another directory. I tried this to build the program:
but I got nearly 10000 lines of
undefined reference
error because of the SDK dependencies. how to show the SDK dependencies that are in thecmake_build
directory to the linker?The text was updated successfully, but these errors were encountered: