user2669704
user2669704

Reputation: 87

why there is no precompiled c++ library for grpc

I'm trying to integrate grpc into C++ projects. but I found the only way is download all source code and compile it by my self.

Is there any way to get a precompile .so/.a file which I can link against and a grpc_cpp_plugin for Linux?

Or is it impossible for c++ to do so and why?

Upvotes: 1

Views: 4321

Answers (2)

hansi_reit
hansi_reit

Reputation: 408

If you are looking for precompiled gRPC libraries you should go with vcpkg. I was also trying to cross compile gRPC, without building the library itself. With vcpkg I achieved this quite well. There are just a few steps to set this up:

  1. Pull vcpkg from GitHub and follow the instructions to set it up
  2. Install grpc with "./vcpkg install grpc"
  3. Set CMAKE_TOOLCHAIN_FILE in your CMakeLists.txt to the "vcpkg.cmake"-file in your vcpkg-folder
  4. Add gRPC in your CMakeLists.txt

Here is my CMakeLists.txt:

cmake_minimum_required(VERSION 3.1)

if(DEFINED ENV{VCPKG_ROOT})
    set(CMAKE_TOOLCHAIN_FILE $ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
else()
    set(CMAKE_TOOLCHAIN_FILE "/path_to_vcpkg/scripts/buildsystems/vcpkg.cmake")
endif()

project(Foo)

find_package(gRPC CONFIG REQUIRED)

...

add_executable(${PROJECT_NAME} ${Bar})

target_link_libraries(${PROJECT_NAME} PRIVATE gRPC::gpr gRPC::grpc gRPC::grpc++ gRPC::grpc_cronet)

In the Folder path_to_vcpkg/packages/grpc_x64-PLATFORM/tools/grpc you will find all the precompiled grpc-plugins for your platform (also grpc_cpp_plugin).

Pros:

  • easy to set up
  • vcpkg is available for all common plattforms
  • if a package isn't needed anymore you can just delete the folder in "path_to_vcpkg/packages"
  • includes all the gRPC tools you need

Cons:

  • the "path_to_vcpkg/packages" folder gets quite big after some packages installed

Upvotes: 3

zmike
zmike

Reputation: 1180

Is there any way to get a precompile .so/.a file which I can link against and a grpc_cpp_plugin for Linux?

To answer this question, the gRPC C++ plugin currently requires manual build and install as stated here: https://grpc.io/blog/installation/

That means that there are currently no precompiled gRPC C++ plugins.

Upvotes: -1

Related Questions