Difference between revisions of "How to create a C++ gRPC application"

From epsciwiki
Jump to navigation Jump to search
Line 5: Line 5:
 
<br>
 
<br>
  
: '''Setup some environmental variables (assuming bash)'''
+
: '''Start by copying the hello world example as it's the simplest and does what we want'''
 
<blockquote>
 
<blockquote>
 
<pre>
 
<pre>
export GRPC_INSTALL_DIR=/daqfs/gRPC/installation
+
cd  /daqfs/gRPC
export PATH="$GRPC_INSTALL_DIR/bin:$PATH"
+
mkdir  -p  ejfat/cpp
export LD_LIBRARY_PATH="$GRPC_INSTALL_DIR/lib:$LD_LIBRARY_PATH"
+
cd  ejfat/cpp
</pre>
+
cp  -r  /daqfs/gRPC/grpc/examples/cpp/helloworld  loadBalancerControl
</blockquote>
+
 
:: The alternative is to run a provided bash setup script which does the same thing
+
 
:: <pre>/daqfs/gRPC/setupgrpc</pre>
 
: '''Clone the repository'''<pre>git clone --recurse-submodules -b v1.50 --depth 1 --shallow-submodules https://github.com/grpc/grpc</pre>
 
: '''Build the package'''
 
<blockquote>
 
<pre>
 
cd grpc
 
mkdir -p cmake/build
 
pushd cmake/build
 
 
cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$GRPC_INSTALL_DIR -DBUILD_SHARED_LIBS=ON ../..
 
cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$GRPC_INSTALL_DIR -DBUILD_SHARED_LIBS=ON ../..
 
make -j 4
 
make -j 4

Revision as of 19:37, 16 December 2022

Steps to take in creating a gRPC application from an example in the C++ gRPC package.


The application in this case is the reporting to the control plane of the fill level of an ERSAP backend reassembler's fifo

Start by copying the hello world example as it's the simplest and does what we want
cd  /daqfs/gRPC
mkdir  -p  ejfat/cpp
cd  ejfat/cpp
cp  -r  /daqfs/gRPC/grpc/examples/cpp/helloworld  loadBalancerControl


cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$GRPC_INSTALL_DIR -DBUILD_SHARED_LIBS=ON ../..
make -j 4
make install
popd

Currently grpc is installed in /daqfs/gRPC/