Compilation errors (No such file "common.h" in protobuf, Could NOT find GFlags, Glog, etc.)

3,566 views
Skip to first unread message

Richard Allen

unread,
Aug 16, 2015, 10:51:46 PM8/16/15
to Caffe Users

Hi. I am having an issue compiling Caffe, and have not been able to find a working solution. I followed the steps on the Caffe installation page, but can't get past compilation (http://caffe.berkeleyvision.org/installation.html#compilation). When I run make all, I get the following 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:9:42: fatal error: google/protobuf/stubs/common.h: No such file or directory
compilation terminated.
make: *** [.build_release/src/caffe/proto/caffe.pb.o] Error 1

I already have all the dependencies listed on the Caffe installation page, but they are already installed in a root directory, and I did not get them by "sudo yum install" which I imagine would do the linking for me--I do not have root permissions to do "sudo yum install". I have tried protobuf 2.6.1, 2.4.1, 2.5.0, all with the same error on make. Since make doesn't seem to work, I have tried all of these versions on cmake as well, which still give me errors like

...
-- Could NOT find GFlags (missing: GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY)
-- Could NOT find Glog (missing: GLOG_INCLUDE_DIR GLOG_LIBRARY)
-- Could NOT find PROTOBUF (missing: PROTOBUF_LIBRARY PROTOBUF_INCLUDE_DIR)
...

I have no clue how to set Caffe to use the right directories. So what I did was manually set these variables to contain all the folders I could find (e.g. setenv PROTOBUF_INCLUDE_DIR /path/to/protobuf/src), and I ran cmake again. This works only for some of the variables, and I cannot get all of them to work, so it still isn't compiling. This solution seems way too cumbersome and error-prone... I don't even know what the LIBRARY directories should be for Glog and GFlags.

Does anybody have any insight on how to get this to work? Please let me know if you need more information. I run Linux.

Thanks.

Thomas Wood

unread,
Aug 17, 2015, 4:29:46 AM8/17/15
to Caffe Users
The way to pass variables through to cmake is

mkdir ../caffe_build && cd ../caffe_build;
cmake -DPROTOBUF_INCLUDE_DIR="/path/to/protobuf" ../caffe

and similarly for different cmake flags.

A good way to see if you have glog and gflags installed is

locate libgflags
locate libglog

for Ubuntu they are a part of the packages

libgoogle-glog*
libgflags*

I'm sure a little bit of digging will show what packages you will need.
Message has been deleted
Message has been deleted

Richard Allen

unread,
Aug 17, 2015, 10:29:05 AM8/17/15
to Caffe Users
I have already set the environment variables, which works for some but not all, probably because it is expecting some sort of file in the directories that it does not see in the directories I give. I don't know which directories to give. For example, if I set PROTOBUF_INCLUDE_DIR to path/to/protobuf/src it works, but if I set GLOG_INCLUDE_DIR to path/to/glog/src it doesn't work. And lmdb doesn't even have a src dir. This seems like a ridiculous way to get things to work--manually setting each environment variable.

I already know what packages I need.. are you referring to the ones listed on the Caffe site? I would just like to tell Caffe where each directory is, but it is not working. There must be a better way in such a widely used software.

Thanks.

Thomas Wood

unread,
Aug 18, 2015, 11:14:34 PM8/18/15
to Caffe Users
It sounds like you might need the liblmdb-dev package that contains the header files if there are absolutely no source directories associated with lmdb whatsoever.

You might also want to look more closely at GLOG_INCLUDE_DIR. The way each project does things with include directories is not always the same. You might need /path/to/glog/include. I've had that problem a hundred times.

In terms of setting things by hand, I have found building caffe to be pretty automatic, iff you use cmake. So definitely give cmake a try.

Here is my command to configure caffe:

cmake -DCMAKE_INSTALL_PREFIX=/usr \    # Ubuntu doesn't use /usr/local so much
-DCUDNN_INCLUDE=/usr/include \                 # Caffe needs the directory here
-DCUDNN_LIBRARY=/usr/lib/libcudnn.so \      # cmake requires an actual file or it says "Cannot link to directory. Dropping target." which is bad
-DCMAKE_ECLIPSE_VERSION=3.8 \            # for nsight
-DBLAS="open" \                                          # don't look for ATLAS or MKL, just use OpenBLAS
-G"Eclipse CDT4 - Unix Makefiles" \               # also for nsight
 ../../../caffe                                                  # I take building out of directory very, very seriously :-)

So you can see I haven't had to tell the static Makefile where everything is located, just a few options for customizing my build. Recommending using a static Makefile first and foremost is asking for trouble IMO. Configuration is important.

pengw...@gmail.com

unread,
Nov 24, 2015, 10:37:10 PM11/24/15
to Caffe Users
Hello sir, have u solved this problem? Ialso fac this issue due to no root permission on the machine in uni.........
If u solve it, hope u can share the way to me.
Looking forward to your reply!

在 2015年8月17日星期一 UTC+12下午2:51:46,Richard Allen写道:
Reply all
Reply to author
Forward
0 new messages