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

Created on 24 May 2019  路  15Comments  路  Source: BVLC/caffe

Important -

Issue summary

Gettingv error while building caffe
running command
make all

Error :

CXX .build_release/src/caffe/proto/caffe.pb.cc
In file included from .build_release/src/caffe/proto/caffe.pb.cc:4:0:
.build_release/src/caffe/proto/caffe.pb.h:10:40: fatal error: google/protobuf/port_def.inc: No such file or directory
compilation terminated.
Makefile:589: recipe for target '.build_release/src/caffe/proto/caffe.pb.o' failed
make: * [.build_release/src/caffe/proto/caffe.pb.o] Error 1

Steps to reproduce

Following installation steps of below link
https://github.com/BVLC/caffe/wiki/Ubuntu-16.04-Installation-Guide

Tried solutions

Installed protobuff as in the below link:

https://askubuntu.com/questions/1072683/how-can-i-install-protoc-on-ubuntu-16-04

System configuration

  • Operating system: Ubuntu 16.04
  • CUDA version (if applicable): V10.0.130
  • CUDNN version (if applicable): 6.0.21

Most helpful comment

see protobuf issue 5868

  • open Makefile.config
  • add protobuf include path in INCLUDE_DIRS
  • add protobuf lib path in LIBRARY_DIRS

It works for me. :)

All 15 comments

that protobuff install page has two installation methods, one was a manual compilation other was installed by:

sudo apt install protobuf-compiler

when I installed caffe on ubuntu and debian it was all done through sudo apt-get installs of dependencies never manual installation so it might make a huge difference

try sudo apt-get remove protobuf-compiler than reinstall via apt-get install

I have the same problem. @400lbhacker suggested solution did not work.

Same error.. Has someone found a solution yet?

@ayadav10491 see #27697

@andreyhristov Hi, could help pinpoint which of the answer in #27697 has the solution? As a new Linux user the answer are too overwhelming to understand. So far all I understand is that they change the makefile on tensorflow but since our problem on caffe is it also applicable ? Thank you

@RichardoTiono @ayadav10491 @msapaydin Have you ever failed to use make before?
You can try make clean.

make clean
make all -j 16

It worked when I met this problem.

@suxb201 I think the problem will still persist. Because when I check the target folder it really doesn't contain those file. The workaround that I used

  1. Find where those file is (in my case on anaconda3)
  2. Insert those path to makefile.config
    and now it compiles but gave other error such as segmentation fault which I haven't found solution yet

May be you try latest-version of protobuf(https://github.com/protocolbuffers/protobuf/releases),such as protobuf-2.9.1(it contains the port_def.inc).
I met the same problem,and re-installed the latest protobuf(2.9.1 version) and removed the old one,re-complier,it worked.

see protobuf issue 5868

  • open Makefile.config
  • add protobuf include path in INCLUDE_DIRS
  • add protobuf lib path in LIBRARY_DIRS

It works for me. :)

@Walstruzz Walstruzz
Could you please tell me the Makefile.config file setting details? I have installed the protobuf in my system.
And the protoc --version command is worked. But I can't find it in my /usr/lib directory. Thx in advance.

@Walstruzz Walstruzz
Could you please tell me the Makefile.config file setting details? I have installed the protobuf in my system.
And the protoc --version command is worked. But I can't find it in my /usr/lib directory. Thx in advance.

@SungYK
Sorry, I compile protobuf from source code.
But I think which protoc and ldd $(which protoc) may help you.

@Walstruzz
Thank you, I try to compile it from source code, and set the path in Makefile.config. It works.

The problem is this:
When I use protoc --version, it shows my system has version 3.7.1.
However, my piped protobuf tells me it hasa version 2.6.1
What should I do in this case???

my solution:
~: find / -name grpc++.pc 2>/dev/null
copy the result(without '/grpc++.pc') to the path bellow
: export PKG_CONFIG_PATH="copy"
:make
if you cannot find openssl, then
: sudo apt-get install libssl-dev

Was this page helpful?
0 / 5 - 0 ratings

Related issues

prathmeshrmadhu picture prathmeshrmadhu  路  3Comments

iamhankai picture iamhankai  路  3Comments

Ruhjkg picture Ruhjkg  路  3Comments

malreddysid picture malreddysid  路  3Comments

vladislavdonchev picture vladislavdonchev  路  3Comments