protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

got errors saying conflicting declaration in protobuf/arena.h

Open yafangshih opened this issue 11 years ago • 10 comments

I've got these errors saying there is conflicting declaration in protobuf/arena.h. I use Protocol Buffers v3.0.0-beta-1, and install it on Ubuntu 14.04 as

$./autogen.sh
$ ./configure
$ make
$ make check
$ make install

How did these errors occur? like because I did sth wrong during installing protobuf or ...? and how can I fix it?

I got the errors when make all the caffe library from https://github.com/bharath272/caffe-sds which uses protobuf.

Thanks a lot.

/usr/local/include/google/protobuf/arena.h:909:38: error: conflicting declaration ‘const google::protobuf::internal::integral_constant<bool, ((sizeof (DestructorSkippable<const T>(static_cast<const T*>(0))) == sizeof (char)) || (google::protobuf::internal::has_trivial_destructor<A>::value == true))> google::protobuf::Arena::is_destructor_skippable<T>::value’
     Arena::is_destructor_skippable<T>::value =
                                      ^
/usr/local/include/google/protobuf/arena.h:589:19: error: ‘google::protobuf::Arena::is_destructor_skippable<T>::value’ has a previous declaration as ‘const type google::protobuf::Arena::is_destructor_skippable<T>::value’
     static const type value;
                   ^
/usr/local/include/google/protobuf/arena.h:909:38: error: declaration of ‘const type google::protobuf::Arena::is_destructor_skippable<T>::value’ outside of class is not definition [-fpermissive]
     Arena::is_destructor_skippable<T>::value =
                                      ^

yafangshih avatar Sep 08 '15 08:09 yafangshih

This seems to be the same error as in: https://github.com/google/protobuf/issues/787

Could you try the patch provided by Yangqing and see if it works for you?

xfxyjwf avatar Sep 08 '15 16:09 xfxyjwf

Yes, it's the same issue. I tried the patch provided by Yangqing and it works!

yafangshih avatar Sep 09 '15 01:09 yafangshih

Hello Yafangshih, I have the same problem. Could you please explain a little bit more what you did to make protobuf work during caffe compilation. Thank you.

jdariasl avatar Sep 10 '15 04:09 jdariasl

I replace the code between line 576 to 590 in /usr/local/include/google/protobuf/arena.h to the following provided by Yangqing

  template<typename T>
  struct is_destructor_skippable {
    template<typename U>
    static char DestructorSkippable(
        const typename U::DestructorSkippable_*);
    template<typename U>
    static double DestructorSkippable(...);

    static const bool skippable =
          sizeof(DestructorSkippable<const T>(static_cast<const T*>(0))) ==
          sizeof(char) || google::protobuf::internal::has_trivial_destructor<T>::value == true;

    // This will resolve to either google::protobuf::internal::true_type or google::protobuf::internal::false_type.
    typedef google::protobuf::internal::integral_constant<bool, skippable> type;
    static const type value;
  };

Hope it works for you.

yafangshih avatar Sep 10 '15 04:09 yafangshih

Thanks @yafangshih, I made the change but the error persists... Now I got this:

/usr/local/include/google/protobuf/arena.h:916:38: error: conflicting declaration ‘const google::protobuf::internal::integral_constant<bool, ((sizeof (DestructorSkippable<const T>(static_cast<const T*>(0))) == sizeof (char)) || (google::protobuf::internal::has_trivial_destructor<T>::value == true))> google::protobuf::Arena::is_destructor_skippable<T>::value’
     Arena::is_destructor_skippable<T>::value =
                                      ^
/usr/local/include/google/protobuf/arena.h:596:19: note: previous declaration as ‘const type google::protobuf::Arena::is_destructor_skippable<T>::value’
     static const type value;
                   ^
/usr/local/include/google/protobuf/arena.h:916:38: error: declaration of ‘const type google::protobuf::Arena::is_destructor_skippable<T>::value’ outside of class is not definition [-fpermissive]
     Arena::is_destructor_skippable<T>::value =
                                      ^
Makefile:549: recipe for target '.build_release/cuda/src/caffe/util/im2col.o' failed
make: *** [.build_release/cuda/src/caffe/util/im2col.o] Error 1

Please let me know if I am doing something wrong.

Thanks a lot.

jdariasl avatar Sep 10 '15 22:09 jdariasl

@jdariasl could you try to this path: https://github.com/xfxyjwf/protobuf/commit/494716a682ef854168e92231a3cdcc89d587d9b9

xfxyjwf avatar Sep 10 '15 22:09 xfxyjwf

It works, thank you so much!

jdariasl avatar Sep 10 '15 23:09 jdariasl

hi is this patch gonna make it to proto's trunk?

christian-lefty avatar Sep 23 '15 15:09 christian-lefty

thanks @yafangshih , it works for me.

ZiangYan avatar Sep 28 '15 08:09 ZiangYan

@xfxyjwf I change the 576 to 590 to the above modified codes, but I get the similar situation like you. How did you fix this later on? Thanks

xxw345 avatar Oct 07 '15 02:10 xxw345