提交 a0a50764 编写于 作者: valerianian's avatar valerianian 提交者: Jin Hai

[skip ci] Update C++ SDK readme. (#973)

* Update README.md

Update C++ SDK readme.

* [skip ci] Update C++ SDK readme.
上级 a5beec86
# 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 ### Build C++ SDK
The C++ SDK source code is under milvus/sdk. You must build the C++ SDK before using it:
If you want to build sdk project, follow below steps:
```shell ```shell
# build project # build C++ SDK
$ cd [Milvus root path]/sdk $ cd [Milvus root path]/sdk
$ ./build.sh $ ./build.sh
``` ```
### Try C++ example ### Try C++ example
Firstly, you need to start a Milvus server. You must have a running Milvus server to try the C++ example. Refer to [Milvus Documentation](https://milvus.io/docs/guides/get_started/install_milvus/install_milvus.md) to learn how to install and run a Milvus server.
If you've already built the entire milvus project, just start Milvus server with the following command:
```shell
# start milvus server
$ cd [Milvus root path]/core
$ ./start_server.sh
```
You can also use Docker to start Milvus server:
```shell
# pull milvus docker image and start milvus server
$ docker pull milvusdb/milvus:latest
$ docker run --runtime=nvidia -p 19530:19530 -d milvusdb/milvus:latest
```
Run C++ example: Run C++ example:
```shell ```shell
# run milvus C++ example # run Milvus C++ example
$ cd [Milvus root path]/sdk/cmake_build/examples/simple $ cd [Milvus root path]/sdk/cmake_build/examples/simple
$ ./sdk_simple $ ./sdk_simple
``` ```
### Make your own C++ client project ### Create your own C++ client project
Create a folder for the project, and copy C++ SDK header and library files into it. Create a folder for the project, and copy C++ SDK header and library files into it.
```shell ```shell
# create project folder # create project folder
$ mkdir MyMilvusClient $ mkdir MyMilvusClient
...@@ -46,8 +45,9 @@ Create a folder for the project, and copy C++ SDK header and library files into ...@@ -46,8 +45,9 @@ Create a folder for the project, and copy C++ SDK header and library files into
$ cp [Milvus root path]/sdk/include/Status.h . $ cp [Milvus root path]/sdk/include/Status.h .
``` ```
Create file main.cpp in the project folder, and copy the following code into it: Create file `main.cpp` in the project folder, and copy the following code into it:
```shell
```c++
#include "./MilvusApi.h" #include "./MilvusApi.h"
#include "./Status.h" #include "./Status.h"
...@@ -64,28 +64,32 @@ int main() { ...@@ -64,28 +64,32 @@ int main() {
} }
``` ```
Create file CMakeList.txt in the project folder, and copy the following code into it: Create file `CMakeLists.txt` in the project folder, and copy the following code into it:
```shell
```bash
cmake_minimum_required(VERSION 3.14) cmake_minimum_required(VERSION 3.14)
project(test) project(test)
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 17)
add_executable(milvus_client main.cpp) add_executable(milvus_client main.cpp)
target_link_libraries(milvus_client target_link_libraries(milvus_client
${PROJECT_SOURCE_DIR}/libmilvus_sdk.so) ${PROJECT_SOURCE_DIR}/libmilvus_sdk.so
pthread)
``` ```
Now there are 5 files in your project: Now there are 5 files in your project:
```shell ```shell
MyMilvusClient MyMilvusClient
|-CMakeList.txt |-CMakeLists.txt
|-main.cpp |-main.cpp
|-libmilvus_sdk.so |-libmilvus_sdk.so
|-MilvusApi.h |-MilvusApi.h
|-Status.h |-Status.h
``` ```
Build the project: Build the project:
```shell ```shell
$ mkdir cmake_build $ mkdir cmake_build
$ cd cmake_build $ cd cmake_build
...@@ -94,6 +98,7 @@ Build the project: ...@@ -94,6 +98,7 @@ Build the project:
``` ```
Run your client program: Run your client program:
```shell ```shell
$ ./milvus_client $ ./milvus_client
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册