milvus/sdk
ireneontheway5 934c90bf26
[skip ci] Update links and fix dead links. (#4496)
* [skip ci] Update links and fix dead links.

Signed-off-by: ireneontheway5 <qingying.hu@zilliz.com>

* [skip ci] Delete spaces.

Signed-off-by: ireneontheway5 <qingying.hu@zilliz.com>

* [skip ci] Delete spaces.

Signed-off-by: ireneontheway5 <qingying.hu@zilliz.com>
2020-12-25 11:55:36 +00:00
..
build-support Optimize clang-tidy workflow for code static analysis (#3432) 2020-08-25 09:39:25 +08:00
cmake C++ sdk sdk_binary needs to update (#4330) 2020-12-01 19:40:31 +08:00
examples Fix search when there are multiple vector fields (#4420) 2020-12-18 14:47:51 +08:00
grpc Change status proto to remove enum ErrorCode and replace it as int type & Remove ErrorMap in Server (#4399) 2020-12-10 15:03:04 +08:00
grpc-gen/gen-milvus Change status proto to remove enum ErrorCode and replace it as int type & Remove ErrorMap in Server (#4399) 2020-12-10 15:03:04 +08:00
include Add an optional parameter naming 'client_tag' on client constructor in c++ sdk (#4377) 2020-12-09 10:36:31 +08:00
interface [skip ci]Update C++ sdk search interface (#4164) 2020-11-12 13:04:33 +08:00
thirdparty/nlohmann merge json to master to get docker image (#1500) 2020-03-07 15:23:34 +08:00
CMakeLists.txt Change status proto to remove enum ErrorCode and replace it as int type & Remove ErrorMap in Server (#4399) 2020-12-10 15:03:04 +08:00
README.md [skip ci] Update links and fix dead links. (#4496) 2020-12-25 11:55:36 +00:00
build.sh Automerge1 (#1984) 2020-04-20 20:39:22 +08:00

README.md

Milvus C++ SDK

Get C++ SDK

If you compile Milvus from source, C++ SDK is already in [Milvus root path]/sdk. If you install Milvus from Docker images, you need to download the whole sdk folder to your host.

Requirements

CMake 3.14 or higher

Build C++ SDK

You must build the C++ SDK before using it:

 # build C++ SDK
 $ cd [Milvus root path]/sdk
 $ ./build.sh

Try C++ example

You must have a running Milvus server to try the C++ example. Refer to Milvus Documentation to learn how to install and run a Milvus server.

Run C++ example:

# run Milvus C++ example
$ cd [Milvus root path]/sdk/cmake_build/examples/simple
$ ./sdk_simple

Create your own C++ client project

  • Create a folder for the project, and copy C++ SDK header and library files into it.
 # create project folder
 $ mkdir MyMilvusClient
 $ cd MyMilvusClient
 
 # copy necessary files
 $ cp [Milvus root path]/sdk/cmake_build/libmilvus_sdk.so .
 $ cp -r [Milvus root path]/sdk/include .
 $ cp -r [Milvus root path]/sdk/thirdparty .
  • Create file main.cpp in the project folder, and copy the following code into it:
#include "./include/MilvusApi.h"
#include "./include/Status.h"

int main() {
  // connect to milvus server
  std::shared_ptr<milvus::Connection> conn = milvus::Connection::Create();
  milvus::ConnectParam param = {"127.0.0.1", "19530"};
  conn->Connect(param);
  
  // put your client code here
  
  milvus::Connection::Destroy(conn);
  return 0;
}
  • Create file CMakeLists.txt in the project folder, and copy the following code into it:
 cmake_minimum_required(VERSION 3.14)
 project(test)
 set(CMAKE_CXX_STANDARD 17)

 include_directories(${PROJECT_SOURCE_DIR})

 add_executable(milvus_client main.cpp)
 target_link_libraries(milvus_client
         ${PROJECT_SOURCE_DIR}/libmilvus_sdk.so
         pthread)
  • Now the file structure of your project:
MyMilvusClient
 |-CMakeLists.txt
 |-main.cpp
 |-libmilvus_sdk.so
 |-include
     |-MilvusApi.h
     |-Status.h
     |-......
  • Build the project:
 $ mkdir cmake_build
 $ cd cmake_build
 $ cmake ..
 $ make
  • Run your client program:
 $ ./milvus_client

Troubleshooting

  • compile error "cannot find -lz"
 $ apt-get install zlib1g-dev.