Skip to content

vesoft-inc/nebula-cpp

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 

How to use cpp client lib

Option One: Get package from github

Down package

wget https://github.com/vesoft-inc/nebula-cpp/releases/download/$release-version/nebula-graph-client-$version.$system.x86_64.rpm

Install lib to local

  • Centos
bash> sudo rpm -ivh nebula-graph-client-$version.$system.x86_64.rpm
  • Ubuntu
bash> sudo dpkg -i nebula-graph-client-$version.$system.amd64.deb

Update the dynamic library cache

bash> ldconfig

Option Two: Build by source code

clone nebula src

git clone https://github.com/vesoft-inc/nebula-cpp.git

build

bash> cd nebula-cpp && mkdir build && cd build
bash> cmake ..
bash> make && sudo make install

If your g++ can't support c++11, you need to configure building by cmake like this

bash> cmake -DDISABLE_CXX11_ABI=ON ..

after finish building, cp the lib and include files to your dir

How to use in your code

  • Step 1: init arvs(a process can only call once)
  • Step 2: init connection pool, the default connections is 10, timeout is 1000 ms (a process can only call once),
  • Step 3: get a session
  • Step 4: execute your statements
  • Step 5: release session

Please refer to the sample code on detail usage.

build and run example code If your g++ version is more than 5.0

LIBRARY_PATH=${Your Installed Library Folder}:$LIBRARY_PATH g++ -std=c++11 SessionExample.cpp -I${Your Installed Include folder} -lnebula_graph_client -o session_example

If your g++ version is less than 5.0

LIBRARY_PATH=${Your Installed Library Folder}:$LIBRARY_PATH g++ -std=c++11 SessionExample.cpp -I${Your Installed Include folder} -lnebula_graph_client -o session_example -D _GLIBCXX_USE_CXX11_ABI=0

Run the example (require a available nebula graph 2.0 server in '127.0.0.1:9669')

LD_LIBRARY_PATH=${Your Installed Library Folder}:$LD_LIBRARY_PATH ./session_example

Or if you're familiar to cmake you could try build and run by cmake directly.

Note: If you install by rpm or deb package, the default install path of rpm or deb package is /usr/local/nebula, the ${Your Installed Library Folder} is /usr/local/nebula/lib or /usr/local/nebula/lib64, the ${Your Installed Include folder} is /usr/local/nebula/include