why there is no precompiled c++ library for grpc

前端 未结 2 1021
故里飘歌
故里飘歌 2021-01-22 14:39

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 .s

相关标签:
2条回答
  • 2021-01-22 15:13

    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.

    0 讨论(0)
  • 2021-01-22 15:35

    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
    0 讨论(0)
提交回复
热议问题