shengjun.li f942f0b823
fix errors in .mds (#4644)
* Updated logo and architecture links. (#2529)

Signed-off-by: PahudPlus <haimeng.cai@zilliz.com>

* Fixed broken links. (#2902)

Signed-off-by: PahudPlus <haimeng.cai@zilliz.com>

* Minor editorial updates. (#2946)

Signed-off-by: Amy Hong <yun.hong@zilliz.com>

* fix cuda version requirement (#2909)

Signed-off-by: Xiangyu Wang <xy.wang@zilliz.com>

* [skip ci] Updated INSTALL.md.  (#3016)

Signed-off-by: Amy Hong <yun.hong@zilliz.com>

* [skip ci] Fixed broken links. (#3304)

Signed-off-by: Amy Hong <yun.hong@zilliz.com>

* [skip ci] update install from code (#3855)

Signed-off-by: shengjun.li <shengjun.li@zilliz.com>

* [skip ci] update cmake version (#4084)

Signed-off-by: shengjun.li <shengjun.li@zilliz.com>

* [skip ci] Update the foundation name. (#4438)

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

* [skip ci] Added a space for readability (#4465)

Added a space between the heart emoji and the word for better readability.

Signed-off-by: Mark Berger <maberger0811@gmail.com>

* [skip ci] Update links and fix dead links. (#4496)

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

* [skip ci] fix errors in mds

Signed-off-by: shengjun.li <shengjun.li@zilliz.com>

Co-authored-by: PahudPlus <64403786+PahudPlus@users.noreply.github.com>
Co-authored-by: JinHai-CN <hai.jin@zilliz.com>
Co-authored-by: AmyYH <68527082+AmyYH@users.noreply.github.com>
Co-authored-by: Wang XiangYu <xy.wang@zilliz.com>
Co-authored-by: ireneontheway5 <75291211+ireneontheway5@users.noreply.github.com>
Co-authored-by: Mark Berger <maberger0811@gmail.com>
2021-01-22 19:16:40 +08:00
..
2020-04-17 21:05:17 +08:00
2020-04-20 20:39:22 +08:00
2021-01-22 19:16:40 +08:00

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 .
  • 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)

 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.