Bugsfounder
Bugsfounder

Reputation: 45

fatal error: google/protobuf/port_def.inc: No such file or directory

i am on ubuntu and i am using libprotoc version 3.15.8 when i run cmake command it successfully done but when i run make -j it's throwing error:

.
.
.
[  8%] Building CXX object CMakeFiles/ConfigServiceCore.dir/main.cpp.o
In file included from /home/bugs/workspace/ReactVision/rv_utils/ConfigService/configservicecore.h:3,
                 from /home/bugs/workspace/ReactVision/rv_utils/ConfigService/main.cpp:3:
/home/bugs/workspace/ReactVision/rv_utils/ConfigService/config_vals.pb.h:10:10: fatal error: google/protobuf/port_def.inc: No such file or directory
   10 | #include <google/protobuf/port_def.inc>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/ConfigServiceCore.dir/build.make:63: CMakeFiles/ConfigServiceCore.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:159: CMakeFiles/ConfigServiceCore.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Upvotes: 4

Views: 8622

Answers (1)

Alexander Kolbeko
Alexander Kolbeko

Reputation: 63

In my case, when I got this error, the project's structure was:

project
|
|-CMakeLists.txt
|-main.cpp
|-proto
  |
  |
  |--CMakeLists.txt
  |--message.proto

To solve it, I had add to add the "proto" module in the main project's CMakeLists.txt:

add_subdirectory(proto) 

Also, you need to add in both CMake's these lines:

find_package(Protobuf REQUIRED)
include_directories(${protobuf_INCLUDE_DIR})

Also, try to look for a variable named something like protobuf_INCLUDE_DIR; there are no guarantees for it's name (Protobuf_*** or protobuf_***).

Upvotes: 3

Related Questions