Generated files fail to compile with release 30.0

112 views
Skip to first unread message

Michelle Eshow

unread,
Mar 14, 2025, 4:52:24 PM3/14/25
to Protocol Buffers
We are upgrading PB from 3.14 to 30.0, on Alma Linux 9, with g++ 11.5.0. We are using it in C++ as well as Java code.

protoc, shared libs, and include files all show the right release -- 30.0. 

The new installs are in /usr/local/... where the old version is in /usr/ directly

When I try to compile our message library using gnu make, we are getting errors around use of Templates in C code and conflicting definitions of PB functions. Does this seem familiar to anyone? Below are detailed examples. We would appreciate any help at all!

Michelle

In file included from /usr/include/c++/11/utility:76,
                 from /usr/local/include/absl/base/optimization.h:37,
                 from /usr/local/include/absl/base/macros.h:36,
                 from /usr/local/include/google/protobuf/port_def.inc:35,
                 from /usr/local/include/google/protobuf/endian.h:20,
                 from /usr/include/sys/types.h:176,
                 from /usr/include/stdlib.h:394,
                 from /usr/include/c++/11/cstdlib:75,
                 from /usr/include/c++/11/bits/stl_algo.h:59,
                 from /usr/include/c++/11/string:52,
                 from AcLandProtobuf.pb.h:10,
                 from AcLandProtobuf.pb.cc:6:
/usr/include/c++/11/initializer_list:99:3: error: template with C linkage
   99 |   template<class _Tp>
      |   ^~~~~~~~

/usr/local/include/google/protobuf/endian.h:161:17: error: conflicting declaration of C function ‘uint64_t google::protobuf::internal::big_endian::ToHost(uint64_t)’
  161 | inline uint64_t ToHost(uint64_t value) {
      |                 ^~~~~~
/usr/local/include/google/protobuf/endian.h:145:17: note: previous declaration ‘uint16_t google::protobuf::internal::big_endian::ToHost(uint16_t)’
  145 | inline uint16_t ToHost(uint16_t value) {

Adam Cozzette

unread,
Mar 14, 2025, 5:13:02 PM3/14/25
to Michelle Eshow, Protocol Buffers
Those errors make it seem like you're somehow including a bunch of C++ headers inside an extern "C" {} block, though I'm not sure why that would happen. One thing to watch out for is that it's important to regenerate your pb.h and pb.cc files with the new protoc if you have not already done so.

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/protobuf/60bc47c1-649c-431d-89ee-982b4dd7c83bn%40googlegroups.com.

Michelle Eshow

unread,
Mar 14, 2025, 6:52:18 PM3/14/25
to Protocol Buffers
Yes, that seems to be it. The compiler also prints:

/usr/include/sys/types.h:27:1: note: ‘extern "C"’ linkage started here
   27 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~

Those are system includes - not sure why it's suddenly a problem. 

Also causing trouble is that ToHost and FromHost are each defined twice in endian.h, in two different namespaces, little_endian and big_endian. No idea why that's a problem.

Anyway thanks for your insights!
Michelle

Michelle Eshow

unread,
Mar 14, 2025, 7:07:22 PM3/14/25
to Protocol Buffers
Ack, I found the bug, it was just a bad include path in the makefile. SIGH.

On Friday, March 14, 2025 at 2:13:02 PM UTC-7 Adam Cozzette wrote:
Reply all
Reply to author
Forward
0 new messages