It's strange that make complains that src/caffe/common.cpp:35:5: error: ‘::gflags’ has not been declared
Here's the full log.
$caffe: make
PROTOC src/caffe/proto/caffe.proto
CXX .build_release/src/caffe/proto/caffe.pb.cc
CXX src/caffe/net.cpp
CXX src/caffe/layer_factory.cpp
CXX src/caffe/util/cudnn.cpp
CXX src/caffe/util/io.cpp
CXX src/caffe/util/db.cpp
CXX src/caffe/util/upgrade_proto.cpp
CXX src/caffe/util/math_functions.cpp
CXX src/caffe/util/insert_splits.cpp
CXX src/caffe/util/benchmark.cpp
CXX src/caffe/util/im2col.cpp
CXX src/caffe/data_transformer.cpp
CXX src/caffe/solver.cpp
CXX src/caffe/internal_thread.cpp
CXX src/caffe/common.cpp
src/caffe/common.cpp: In function ‘void caffe::GlobalInit(int*, char***)’:
src/caffe/common.cpp:35:5: error: ‘::gflags’ has not been declared
::gflags::ParseCommandLineFlags(pargc, pargv, true);
^
make: *** [.build_release/src/caffe/common.o] Error 1
gflags header is available here /usr/local/include/gflags/gflags.h
Since your gflags is in /usr/local, I guess you installed it manually. Which version did you install?
Correct. I installed manually because our Ubuntu version is 12.04 and hence could not install via apt-get install.
I installed directly from the source cloned (today) from GItHub.
gflags 2.1 changed the name of the namespace from google to gflags.
Caffe probably doesn't handle the latest changes made to the gflags header in 2.1, but there is already an attempt to do so in the code:
https://github.com/BVLC/caffe/blob/master/include/caffe/common.hpp#L21-L28
You should probably try with gflags 2.0, it should work. Or try to fix Caffe for gflags 2.1; the contribution would be welcome :)
Thanks. Removing the ifndef works; but I don't know how to fix it in a more robust way tho.
Closing as this sounds like a library/header mismatch; the ifndef block should never trigger using a gflags 2.1 header.
That said, we can probably remove that block entirely (per the comment), as the latest version of gflags claims to have resolved the namespace issues.
I also got this problem, and I installed gflags by myself before .
And I solved this problem :
in the file include/caffe/common.hpp
//#ifndef GFLAGS_GFLAGS_H_
namespace gflags = google;
//#endif // GFLAGS_GFLAGS_H_
comment ;
namespace gflags = google;
this code is important
@MuMuJun97 yes this very important
@flx42 why this issue is not fixed it is 2019 now
caffe is very difficult install in Centos 7
Most helpful comment
I also got this problem, and I installed gflags by myself before .
And I solved this problem :
in the file
include/caffe/common.hppcomment ;
namespace gflags = google;this code is important