Solaris 10 SPARC 64上的Protobuf-2.6.1编译错误

时间:2015-12-02 07:43:26

标签: c++ gcc solaris-10 protobuf-c pointer-conversion

当尝试在Solaris 10 SPARC 64上编译Protobuf-2.6.1时,我得到:

./google/protobuf/stubs/once.h: In function `void google::protobuf::GoogleOnceInit(google::protobuf::ProtobufOnceType*, void (*)())':
./google/protobuf/stubs/once.h:125: error: cannot convert `google::protobuf::ProtobufOnceType*' to `const volatile google::protobuf::internal::Atomic32*' for argument `1' to `google::protobuf::internal::Atomic32 google::protobuf::internal::Acquire_Load(const volatile google::protobuf::internal::Atomic32*)'
./google/protobuf/stubs/once.h: In function `void google::protobuf::GoogleOnceInit(google::protobuf::ProtobufOnceType*, void (*)(Arg*), Arg*)':
./google/protobuf/stubs/once.h:134: error: cannot convert `google::protobuf::ProtobufOnceType*' to `const volatile google::protobuf::internal::Atomic32*' for argument `1' to `google::protobuf::internal::Atomic32 google::protobuf::internal::Acquire_Load(const volatile google::protobuf::internal::Atomic32*)'

我关注了官方自述文件,./configuremake

编译器版本(GCC):

$ gcc -v
Reading specs from /usr/sfw/lib/gcc/sparc-sun-solaris2.10/3.4.3/specs
Configured with: /sfw10/builds/build/sfw10-patch/usr/src/cmd/gcc/gcc-3.4.3/configure --prefix=/usr/sfw --with-as=/usr/ccs/bin/as --without-gnu-as --with-ld=/usr/ccs/bin/ld --without-gnu-ld --enable-languages=c,c++ --enable-shared
Thread model: posix
gcc version 3.4.3 (csl-sol210-3_4-branch+sol_rpath) 

我也阅读了问题protobuf generated files does not compile on Solaris SPARC 64并尝试了,但它没有用。那篇文章适用于Protobuf-2.4.1,但Protobuf-2.6.1有所改变:

2014-10-20 version 2.6.1:

  C++
  * Added atomicops support for Solaris.

有没有办法让GCC强制指针转换?

1 个答案:

答案 0 :(得分:1)

我根据github问题#789

解决了问题

主要原因是本期第4点的问题。预定义的SOLARIS_64BIT_ENABLED宏根本不起作用。

只需将-m64 -DSOLARIS_64BIT_ENABLED添加到CXXFLAGS和CFLAGS即可解决问题。但是,如问题所示,进行整体修改会更好。