Trouble Compiling and Linking library under Windows 7

33 views
Skip to first unread message

Ricardo Iglesias

unread,
Jul 2, 2019, 8:26:48 PM7/2/19
to Protocol Buffers
Good evening. I'm currently attempting to integrate the protocol buffer library into an embedded code project I'm assigned to, which uses Windows 7 to flash code onto hardware.

I have followed this guide to installing the protocol buffer libraries/binaries on windows, and believe I am very close to getting my project to compile. Currently, I have the following directory structure:

Desktop
  install
    bin
    include
    lib
 
ProtoTest
    data_revised
.pb.h
    data_revised.pb.cc
    main.cc


Where ProtoTest is where the code I want to compile resides, and the install folder resulting from the compilation contains the binary for the protobuffer compiler, as well as the includes and libraries.

I wish to run the following command:
g++ -std=c++14 -L/cygdrive/c/Users/<username>/Desktop/install/lib/ \
-lprotobuf \
-I/cygdrive/c/Users/<username>
/Desktop/install/include \
ProtoTest/data_revised.pb.cc ProtoTest/main.cc

However, when I run it, I get errors of this form:
 g++ -std=c++14 -L/cygdrive/c/Users/solarcar/Desktop/install/lib/ -lprotobuf -I/cygdrive/c/Users/solarcar/Desktop/install/include ProtoTest/data_revised.pb.cc ProtoTest/main.cc

In file included from ProtoTest/data_revised.pb.cc:4:0:
ProtoTest/data_revised.pb.h:181:8: error: 'void IntTriplet::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const' marked 'final', but is not virtual
   void SerializeWithCachedSizes(
        ^~~~~~~~~~~~~~~~~~~~~~~~
ProtoTest/data_revised.pb.h:183:35: error: 'google::protobuf::uint8* IntTriplet::InternalSerializeWithCachedSizesToArray(google::protobuf::uint8*) const' marked 'final', but is not virtual
   ::PROTOBUF_NAMESPACE_ID::uint8* InternalSerializeWithCachedSizesToArray(
  

If I recompile the protocol buffer I'm using, I get slightly different errors:
/tmp/ccRjenfk.o:data_revised.pb.cc:(.text+0x22): undefined reference to
google::protobuf::internal::VerifyVersion(int, int, char const*)
or
...:data_revised.pb.cc:...:undefined reference to "google::protobuf::Message::SpaceUsedLong() const"


I'm a bit more lost as to how to fix this more recent error, since I am (hopefully) including the libraries correctly.

Is there any way I can verify the library is indeed being installed correctly?

Ricardo Iglesias

unread,
Jul 2, 2019, 8:30:55 PM7/2/19
to Protocol Buffers
I'm not sure if this would necessarily change anything, but I should mention that I'm running all of this through the Cygwin application, which came with cmake, make, and g++ (which is how I compiled the library in teh first place).

Adam Cozzette

unread,
Jul 3, 2019, 5:15:22 PM7/3/19
to Ricardo Iglesias, Protocol Buffers
It looks like you are mixing one version of protoc with a different version of the protobuf runtime (i.e. libprotobuf). It's important for the protobuf generated code to be built with a protoc of the same version as the runtime library.

--
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 post to this group, send email to prot...@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/6bb6579a-d524-4cbe-8a3a-ea6978485f6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ricardo Iglesias

unread,
Jul 7, 2019, 2:04:10 PM7/7/19
to Protocol Buffers
This wasn't the issue. It compiled just fine when I moved the
-lprotobuf
to the end of the compilation.

Additionally, I'm not sure why the libprotobuf would be a different version, since I had followed the steps on the github readme to get both the protoc and the libprotobuf. The code runs fine for now.
To unsubscribe from this group and stop receiving emails from it, send an email to prot...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages