grpc icon indicating copy to clipboard operation
grpc copied to clipboard

Errors compiling with external protobuf and abseil

Open jgornowich opened this issue 4 years ago • 6 comments

What version of gRPC and what language are you using?

grpc v1.30.2

What operating system (Linux, Windows,...) and version?

Linux Mint 19

What runtime / compiler are you using (e.g. python version or version of gcc)

gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

What did you do? What did you expect to see? What did you see instead?

I am trying to build protobuf against external installations of abseil and protobuf that are not in the standard system installation locations, ie /usr/include. In doing this I had to overcome two specific issues that I wanted to get clarification on usage or input so that I could help contribute the modifications back to the repo.

  1. Issues with referencing an external directory for protobuf installation.

When I specified the -DgRPC_PROTOBUF_PROVIDER=package flag at build time, the FindProtobuf.cmake file does not resolve the installation without additional information. I was able to make this work by providing the -DProtobuf_ROOT=${protobuf_install_location} and -DCMAKE_POLICY_DEFAULT_CMP0074=NEW flags at build time as well. A couple of suggested improvements here could make this easier, either adding the cmake_policy(SET CMP0074 NEW) insde the cmake/protobuf.cmake file or potentially exposing an additional variable like -DgRPC_PROTOBUF_ROOT. Also adding some addition documentation on how to handle this specific case.

  1. Abseil package provider not available.

When specifying -DgRPC_ABSL_PROVIDER=package flag there is an error:

CMake Error at cmake/abseil-cpp.cmake:38 (find_package):
  Could not find a package configuration file provided by "absl" with any of
  the following names:
abslConfig.cmake
absl-config.cmake

Even with the CMP0074 policy set, something like adding DABSL_ROOT=${abseil_install_location} still does not work. I was able to make it work by providing the install location with the -DCMAKE_PREFIX_PATH argument. Maybe either making some adjustments in cmake/abseil-cpp.cmake or adding a new cmake/modules/FindAbsl.cmake file would make this behavior a little more natural?

Anything else we should know about your project / environment?

I am using cmake version 3.18.0

jgornowich avatar Jul 29 '20 19:07 jgornowich

Get exactly the same issue trying to install to docker with the following dockerfile:

FROM debian:stretch

RUN apt-get update && apt-get install -y \
  build-essential autoconf libtool git pkg-config cmake \
  && apt-get clean

# install protobuf first, then grpc
ENV GRPC_RELEASE_TAG v1.35.x
RUN git clone -b ${GRPC_RELEASE_TAG} https://github.com/grpc/grpc /var/local/git/grpc && \
    cd /var/local/git/grpc && \
    git submodule update --init && \
    echo "--- installing protobuf ---" && \
    mkdir -p cmake/build && \
    cd cmake/build && \
    cmake ../.. && \
    make && \
    cmake ../.. -DgRPC_INSTALL=ON -DCMAKE_BUILD_TYPE=Release -DgRPC_ABSL_PROVIDER=package \
      -DgRPC_CARES_PROVIDER=package -DgRPC_PROTOBUF_PROVIDER=package -DgRPC_RE2_PROVIDER=package \
      -DgRPC_SSL_PROVIDER=package -DgRPC_ZLIB_PROVIDER=package && \
    make && make install

Tried both ENV GRPC_RELEASE_TAG v1.35.x and v1.37.x with the same error.

Scrier avatar Mar 30 '21 15:03 Scrier

I was able to make it work by providing the install location with the -DCMAKE_PREFIX_PATH argument. Maybe either making some adjustments in cmake/abseil-cpp.cmake or adding a new cmake/modules/FindAbsl.cmake file would make this behavior a little more natural?

@jgornowich, could you provide the command that got it working for you?

vlopezferrando avatar May 03 '21 15:05 vlopezferrando

Friendly ping as this is still reproducible

Slids avatar Nov 20 '21 15:11 Slids

Still reproducible :(

ILikeIneine avatar Apr 12 '22 02:04 ILikeIneine

Still having the problem in ~2023~ 2024.

flavienbwk avatar Dec 30 '23 12:12 flavienbwk

looks like the "lang/other" tag resulted in this not getting attention.. should have been C++

yashykt avatar Jan 26 '24 01:01 yashykt

@jgornowich How did you install protobuf and absl? We install protobuf and absl in our CI and haven't run into such issues.

yashykt avatar Mar 26 '24 19:03 yashykt

@Scrier In your example, I don't see a command to install protobuf.

yashykt avatar Mar 26 '24 20:03 yashykt

@yashykt : I am not installing it , im building it from source and installing it. with the make && make install

Scrier avatar Apr 02 '24 08:04 Scrier

@Scrier I meant that your commands use gRPC_PROTOBUF_PROVIDER=package but it doesn't seem that you are installing protobuf. Can you remove that option and try again?

yashykt avatar Apr 02 '24 19:04 yashykt

More than 30 days have passed since label "disposition/requires reporter action" was added. Closing this issue. Please feel free to re-open/create a new issue if this is still relevant.

grpc-bot avatar May 10 '24 00:05 grpc-bot