Do you plan to link statically or dynamically against the protobuf library?
If you can link against it statically, I think you may find that the linker
is able to remove a lot of unused code. For Android (which is an
environment where we care a lot about code size), what we generally do is:
- Use lite protos only (i.e. set option optimize_for = LITE_RUNTIME in
every .proto file)
- Link against libprotobuf-lite and not libprotobuf
- Pass -ffunction-sections and -fdata-sections to the compiler and
-Wl,-gc-sections to the linker to maximize the linker's ability to strip
out unused code

On Sun, Dec 2, 2018 at 10:34 PM Roy Barda <royba...@gmail.com> wrote:

> Hi,
>
> I have build protobuf on my Ubuntu environment and saw that the libraries
> size are extremely big.
>
> 28 MB for libprotobuf.
> 4 MB for libprotobuf-lite
>
> I'm aware of nanopb project but I need to use gRPC with protobuf and there
> is no good, working and maintained solution for nanopb.
>
> I followed the regular build process when I built protobuf (with no
> special configuration)
>
> Is there any way to reduce the protobuf library footprint? We are looking
> for a 1MB solution.
>
> Thanks,
>
> Roy.
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to