mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-01 11:29:48 +08:00
da55622042
* write error Signed-off-by: groot <yihua.mo@zilliz.com> * out of storage Signed-off-by: groot <yihua.mo@zilliz.com> * clang format Signed-off-by: groot <yihua.mo@zilliz.com> * fix ut Signed-off-by: groot <yihua.mo@zilliz.com> * fix #1955 Signed-off-by: groot <yihua.mo@zilliz.com> * refine code Signed-off-by: groot <yihua.mo@zilliz.com> * compact threashold Signed-off-by: groot <yihua.mo@zilliz.com> * changelog Signed-off-by: groot <yihua.mo@zilliz.com> * search by id for hnsw/pq/annoy Signed-off-by: groot <yihua.mo@zilliz.com> * fix python test Signed-off-by: yhmo <yihua.mo@zilliz.com> * file cleanup timeout config Signed-off-by: yhmo <yihua.mo@zilliz.com> * typo Signed-off-by: yhmo <yihua.mo@zilliz.com> * changelog Signed-off-by: yhmo <yihua.mo@zilliz.com> |
||
---|---|---|
.. | ||
build-support | ||
cmake | ||
examples | ||
grpc | ||
grpc-gen | ||
include | ||
interface | ||
thirdparty/nlohmann | ||
build.sh | ||
CMakeLists.txt | ||
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 [Milvus root path]/sdk/include/MilvusApi.h .
$ cp [Milvus root path]/sdk/include/Status.h .
Create file main.cpp
in the project folder, and copy the following code into it:
#include "./MilvusApi.h"
#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 there are 5 files in your project:
MyMilvusClient
|-CMakeLists.txt
|-main.cpp
|-libmilvus_sdk.so
|-MilvusApi.h
|-Status.h
Build the project:
$ mkdir cmake_build
$ cd cmake_build
$ cmake ..
$ make
Run your client program:
$ ./milvus_client