Grpc: using grpc C++ without installing it

Created on 28 Jun 2016  路  2Comments  路  Source: grpc/grpc

Sometimes, for example, when you do not have root access to a machine, one cannot make install grpc.

In those cases, when trying to compile the C++ examples compilation fails, as it assumes the library, include, and pkg-config files are installed to /usr/local.

I suggest to have a file, like actviate.sh, that users could source, and it would add all relevant libraries from the source tree to the relevant environment variables.

Here is the script I came up with:

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export PATH=$PATH:$DIR/bins/opt:$DIR/bins/opt/protobuf
export CPATH=$DIR/include:$DIR/third_party/protobuf/src
export LIBRARY_PATH=$DIR/libs/opt:$DIR/libs/opt/protobuf
export PKG_CONFIG_PATH=$DIR/libs/opt/pkgconfig:$DIR/third_party/protobuf
export LD_LIBRARY_PATH=$DIR/libs/opt

In the README one should addd, that to compile grpc without installation one would simply

$ source ~/grpc/activate.sh
$ cd ~/grpc/examples/cpp/helloworld
$ make

That would have been useful for me.
Do you think it would be a good idea?

dispositiohelp wanted kinenhancement lanc++ prioritP3

Most helpful comment

For future reference, zsh compatible activate.sh script

if [ -n "$ZSH_VERSION" ]; then
   DIR="$( cd "$( dirname "${(%):-%N}" )" && pwd )"
elif [ -n "$BASH_VERSION" ]; then
   DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
fi
export PATH=$PATH:$DIR/bins/opt:$DIR/bins/opt/protobuf
export CPATH=$DIR/include:$DIR/third_party/protobuf/src
export LIBRARY_PATH=$DIR/libs/opt:$DIR/libs/opt/protobuf
export PKG_CONFIG_PATH=$DIR/libs/opt/pkgconfig:$DIR/third_party/protobuf
export LD_LIBRARY_PATH=$DIR/libs/opt

All 2 comments

For future reference, zsh compatible activate.sh script

if [ -n "$ZSH_VERSION" ]; then
   DIR="$( cd "$( dirname "${(%):-%N}" )" && pwd )"
elif [ -n "$BASH_VERSION" ]; then
   DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
fi
export PATH=$PATH:$DIR/bins/opt:$DIR/bins/opt/protobuf
export CPATH=$DIR/include:$DIR/third_party/protobuf/src
export LIBRARY_PATH=$DIR/libs/opt:$DIR/libs/opt/protobuf
export PKG_CONFIG_PATH=$DIR/libs/opt/pkgconfig:$DIR/third_party/protobuf
export LD_LIBRARY_PATH=$DIR/libs/opt

It is possible to use grpc C++ without needing to install to /, e.g.:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GoldwinLeong picture GoldwinLeong  路  3Comments

charliesneath picture charliesneath  路  3Comments

aynaylan picture aynaylan  路  3Comments

mlstudies picture mlstudies  路  3Comments

draft6 picture draft6  路  3Comments