15

When I am doing a cmake in the build directory of the project I am getting this error. Initially I got a

protobuf-config.cmake not found

error. So I gave a path of the protobuf-config.cmake file to Protobuf_DIR. Later it started to show this new error:

CMake Error at /opt/cmake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message): Could NOT find Protobuf (missing: Protobuf_PROTOC_EXECUTABLE)

(found suitable version "3.6.1", minimum required is "3.0.0")

I am also attaching the error log file: https://drive.google.com/open?id=1y7BZ6lDBtxvla7r-o188xM_FjwLqwhCx

I am doing this on Ubuntu-18 with cmake version: 3.13 and protobuf version: 3.6.1

denfromufa
  • 5,610
  • 13
  • 81
  • 138
Check
  • 169
  • 1
  • 1
  • 9
  • I see that your question is tagged with spack. From the provided log, it is visible that you are in reality trying to use the spack provided protobuf. Can you list files and directories inside of the protobuf-3.6.1 directory? Also, it would be good to know which specs you used while you built protobuf. – robertm.tum Mar 05 '21 at 11:12

5 Answers5

19

You probably don't have the Protobuf compiler and development files installed. To fix that, run this command:

sudo apt-get install protobuf-compiler libprotobuf-dev

Alternatively, if you're building Protobuf by hand, you can't build it with the build type as RelWithDebInfo because that causes issues with the library and CMake.

S.S. Anne
  • 15,171
  • 8
  • 38
  • 76
  • " can't build it with the build type as RelWithDebInfo because that causes issues with the library and CMake " - why? – denfromufa Feb 18 '20 at 19:36
  • @denfromufa I'm not entirely sure. I had issues with this before and it was because I was building RelWithDebInfo. Maybe it has something to do with the optimizations and the debug information clashing? – S.S. Anne Feb 18 '20 at 20:27
  • I know, I'm a bit late for the party but I don't think he wanted to use missing dependency, protobuf, deployed with APT but rather with spack. The question is why spack didn't deploy protobuf properly or why CMake didn't detect the binary properly. – robertm.tum Mar 05 '21 at 11:17
  • @robertm.tum Looks like someone added the spack tag after I added my answer – S.S. Anne Mar 19 '23 at 23:56
1

Installed from apt on Ubuntu 20.04, dont have permissions to /usr/include/google

To fix: sudo chmod +Xr -R /usr/include/google

Thnesko
  • 108
  • 2
  • 4
0

Default repositories usually contain outdated protobuf version. It is best to install it manually, from sources:

git clone --progress -b v3.10.0 https://github.com/protocolbuffers/protobuf && \
    ( \
      cd protobuf; \
      mkdir build; \
      cd build; \
      cmake ../cmake \
        -DCMAKE_BUILD_TYPE=Release \
        -Dprotobuf_BUILD_SHARED_LIBS=ON \
        -Dprotobuf_BUILD_TESTS=OFF; \
      make -j4 install; \
    ) && \
    rm -rf protobuf
warchantua
  • 1,154
  • 1
  • 10
  • 24
0

Quickly adding here that after installing Protobuf following this answer, I had to delete the build folder in my workspace to get cmake to run without this error :)

frietz58
  • 41
  • 4
-2

Hy,

list your protobuf libraries with sudo apt list | grep protobuf it should tell you what it will install by default. Run protoc --version so that you see what is recognized by default now. And after that get a version from github if needed build it and install it (this should not take to long). Then run protoc --version again.

Marko Bencik
  • 368
  • 2
  • 13