Can't get Caffe to compile

1,918 views
Skip to first unread message

Jonathan S

unread,
Apr 2, 2015, 2:38:22 PM4/2/15
to caffe...@googlegroups.com
I'm sure it's something simple, but the error I get is:



./include/caffe/blob.hpp:53:22: error: ‘BlobShape’ does not name a type
   void Reshape(const BlobShape& shape);
                      ^
./include/caffe/blob.hpp:53:33: error: ISO C++ forbids declaration of ‘shape’ with no type [-fpermissive]
   void Reshape(const BlobShape& shape);
                                 ^
src/caffe/blob.cpp:40:33: error: ‘BlobShape’ does not name a type
 void Blob<Dtype>::Reshape(const BlobShape& shape) {
                                 ^
src/caffe/blob.cpp:40:44: error: ISO C++ forbids declaration of ‘shape’ with no type [-fpermissive]
 void Blob<Dtype>::Reshape(const BlobShape& shape) {
                                            ^
In file included from ./include/caffe/common.hpp:6:0,
                 from ./include/caffe/blob.hpp:8,
                 from src/caffe/blob.cpp:4:
src/caffe/blob.cpp: In member function ‘void caffe::Blob<Dtype>::Reshape(const int&)’:
src/caffe/blob.cpp:41:18: error: request for member ‘dim_size’ in ‘shape’, which is of non-class type ‘const int’
   CHECK_LE(shape.dim_size(), kMaxBlobAxes);
                  ^
src/caffe/blob.cpp:42:31: error: request for member ‘dim_size’ in ‘shape’, which is of non-class type ‘const int’
   vector<int> shape_vec(shape.dim_size());
                               ^
src/caffe/blob.cpp:43:29: error: request for member ‘dim_size’ in ‘shape’, which is of non-class type ‘const int’
   for (int i = 0; i < shape.dim_size(); ++i) {
                             ^
src/caffe/blob.cpp:44:26: error: request for member ‘dim’ in ‘shape’, which is of non-class type ‘const int’
     shape_vec[i] = shape.dim(i);
                          ^
src/caffe/blob.cpp: In member function ‘bool caffe::Blob<Dtype>::ShapeEquals(const caffe::BlobProto&)’:
src/caffe/blob.cpp:393:33: error: ‘const class caffe::BlobProto’ has no member named ‘shape’
   vector<int> other_shape(other.shape().dim_size());
                                 ^
src/caffe/blob.cpp:394:29: error: ‘const class caffe::BlobProto’ has no member named ‘shape’
   for (int i = 0; i < other.shape().dim_size(); ++i) {
                             ^
src/caffe/blob.cpp:395:28: error: ‘const class caffe::BlobProto’ has no member named ‘shape’
     other_shape[i] = other.shape().dim(i);
                            ^
src/caffe/blob.cpp: In member function ‘void caffe::Blob<Dtype>::FromProto(const caffe::BlobProto&, bool)’:
src/caffe/blob.cpp:447:26: error: ‘const class caffe::BlobProto’ has no member named ‘shape’
       shape.resize(proto.shape().dim_size());
                          ^
src/caffe/blob.cpp:448:33: error: ‘const class caffe::BlobProto’ has no member named ‘shape’
       for (int i = 0; i < proto.shape().dim_size(); ++i) {
                                 ^
src/caffe/blob.cpp:449:26: error: ‘const class caffe::BlobProto’ has no member named ‘shape’
         shape[i] = proto.shape().dim(i);
                          ^
src/caffe/blob.cpp: In member function ‘void caffe::Blob<Dtype>::ToProto(caffe::BlobProto*, bool) const’:
src/caffe/blob.cpp:471:10: error: ‘class caffe::BlobProto’ has no member named ‘clear_shape’
   proto->clear_shape();
          ^
src/caffe/blob.cpp:473:12: error: ‘class caffe::BlobProto’ has no member named ‘mutable_shape’
     proto->mutable_shape()->add_dim(shape_[i]);
            ^
make: *** [.build_release/src/caffe/blob.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from ./include/caffe/util/io.hpp:11:0,
                 from src/caffe/util/io.cpp:18:
./include/caffe/blob.hpp:53:22: error: ‘BlobShape’ does not name a type
   void Reshape(const BlobShape& shape);
                      ^
./include/caffe/blob.hpp:53:33: error: ISO C++ forbids declaration of ‘shape’ with no type [-fpermissive]
   void Reshape(const BlobShape& shape);
                                 ^
make: *** [.build_release/src/caffe/util/io.o] Error 1
In file included from ./include/caffe/util/io.hpp:11:0,
                 from src/caffe/util/upgrade_proto.cpp:10:
./include/caffe/blob.hpp:53:22: error: ‘BlobShape’ does not name a type
   void Reshape(const BlobShape& shape);
                      ^
./include/caffe/blob.hpp:53:33: error: ISO C++ forbids declaration of ‘shape’ with no type [-fpermissive]
   void Reshape(const BlobShape& shape);
                                 ^
make: *** [.build_release/src/caffe/util/upgrade_proto.o] Error 1
In file included from ./include/caffe/layer.hpp:8:0,
                 from src/caffe/layers/threshold_layer.cpp:3:
./include/caffe/blob.hpp:53:22: error: ‘BlobShape’ does not name a type
   void Reshape(const BlobShape& shape);
                      ^
./include/caffe/blob.hpp:53:33: error: ISO C++ forbids declaration of ‘shape’ with no type [-fpermissive]
   void Reshape(const BlobShape& shape);
                                 ^
make: *** [.build_release/src/caffe/layers/threshold_layer.o] Error 1
In file included from ./include/caffe/net.hpp:10:0,
                 from src/caffe/solver.cpp:7:
./include/caffe/blob.hpp:53:22: error: ‘BlobShape’ does not name a type
   void Reshape(const BlobShape& shape);
                      ^
./include/caffe/blob.hpp:53:33: error: ISO C++ forbids declaration of ‘shape’ with no type [-fpermissive]
   void Reshape(const BlobShape& shape);
                                 ^
make: *** [.build_release/src/caffe/solver.o] Error 1
In file included from ./include/caffe/layer.hpp:8:0,
                 from src/caffe/layers/slice_layer.cpp:4:
./include/caffe/blob.hpp:53:22: error: ‘BlobShape’ does not name a type
   void Reshape(const BlobShape& shape);
                      ^
./include/caffe/blob.hpp:53:33: error: ISO C++ forbids declaration of ‘shape’ with no type [-fpermissive]
   void Reshape(const BlobShape& shape);
                                 ^
In file included from ./include/caffe/common.hpp:6:0,
                 from ./include/caffe/blob.hpp:8,
                 from ./include/caffe/layer.hpp:8,
                 from src/caffe/layers/slice_layer.cpp:4:
src/caffe/layers/slice_layer.cpp: In member function ‘virtual void caffe::SliceLayer<Dtype>::LayerSetUp(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<caffe::Blob<Dtype>*>&)’:
src/caffe/layers/slice_layer.cpp:14:23: error: ‘const class caffe::SliceParameter’ has no member named ‘has_axis’
   CHECK(!(slice_param.has_axis() && slice_param.has_slice_dim()))
                       ^
src/caffe/layers/slice_layer.cpp: In member function ‘virtual void caffe::SliceLayer<Dtype>::Reshape(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<caffe::Blob<Dtype>*>&)’:
src/caffe/layers/slice_layer.cpp:36:61: error: ‘const class caffe::SliceParameter’ has no member named ‘axis’
     slice_axis_ = bottom[0]->CanonicalAxisIndex(slice_param.axis());
                                                             ^
make: *** [.build_release/src/caffe/layers/slice_layer.o] Error 1
In file included from ./include/caffe/layer.hpp:8:0,
                 from src/caffe/net.cpp:9:
./include/caffe/blob.hpp:53:22: error: ‘BlobShape’ does not name a type
   void Reshape(const BlobShape& shape);
                      ^
./include/caffe/blob.hpp:53:33: error: ISO C++ forbids declaration of ‘shape’ with no type [-fpermissive]
   void Reshape(const BlobShape& shape);
                                 ^
In file included from ./include/caffe/common.hpp:6:0,
                 from src/caffe/net.cpp:8:
src/caffe/net.cpp: In member function ‘void caffe::Net<Dtype>::Init(const caffe::NetParameter&)’:
src/caffe/net.cpp:51:46: error: ‘class caffe::NetParameter’ has no member named ‘input_shape_size’
   CHECK(param.input_dim_size() == 0 || param.input_shape_size() == 0)
                                              ^
src/caffe/net.cpp:58:40: error: ‘class caffe::NetParameter’ has no member named ‘input_shape_size’
     CHECK_EQ(param.input_size(), param.input_shape_size())
                                        ^
src/caffe/net.cpp: In member function ‘void caffe::Net<Dtype>::AppendTop(const caffe::NetParameter&, int, int, std::set<std::basic_string<char> >*, std::map<std::basic_string<char>, int>*)’:
src/caffe/net.cpp:356:37: error: ‘const class caffe::NetParameter’ has no member named ‘input_shape’
         blob_pointer->Reshape(param.input_shape(top_id));
                                     ^
make: *** [.build_release/src/caffe/net.o] Error 1
In file included from ./include/caffe/data_layers.hpp:11:0,
                 from src/caffe/layers/image_data_layer.cpp:9:
./include/caffe/blob.hpp:53:22: error: ‘BlobShape’ does not name a type
   void Reshape(const BlobShape& shape);
                      ^
./include/caffe/blob.hpp:53:33: error: ISO C++ forbids declaration of ‘shape’ with no type [-fpermissive]
   void Reshape(const BlobShape& shape);
                                 ^
make: *** [.build_release/src/caffe/layers/image_data_layer.o] Error 1


Dzung Nguyen

unread,
Jun 23, 2015, 4:55:02 PM6/23/15
to caffe...@googlegroups.com
I am having the same compilation problem. Have you fixed it yet?

J. Yegerlehner

unread,
Jun 23, 2015, 6:02:51 PM6/23/15
to caffe...@googlegroups.com
I don't know if this is happening in your particular case, but I saw similar problem a while back because I had the proto-generated caffe.pb.h file from an old build sitting around. So I would search the file system for that file, and see if you the compiler might be finding an old version of that file sitting around, which you'll want to delete. It sounds similar because the compiler doesn't think "BlobShape" is a type, and it is a proto-generated type.

In my case, I think the  Makefile build had put the caffe.pb.h someplace where the cmake build found it, and so cmake build was trying to include the old out-of-date caffe.pb.h.

Dzung Nguyen

unread,
Jun 23, 2015, 7:05:19 PM6/23/15
to caffe...@googlegroups.com
Thanks, this is indeed the reason for compilation error!

Mohamed Dahmane

unread,
Nov 6, 2015, 2:18:07 PM11/6/15
to Caffe Users
Reply all
Reply to author
Forward
0 new messages