If you invoke protoc like:
  protoc --cpp_out=dllexport_decl=MY_EXPORT_MACRO:path/to/output/dir

then it will generate code with MY_EXPORT_MACRO in all the right places.
 However, this option is incomplete -- currently there is no way to force
the generated .pb.h to #include a header which defines MY_EXPORT_MACRO.  I'm
open to patches to fix this.  Or, you could use a hack to work around it,
such as adding the #include via some sort of text processing after protoc
finishes, or perhaps moving the .pb.h to .pb2.h and replacing the .pb.h file
with one that first includes your header then includes the .pb2.h...

On Tue, Sep 22, 2009 at 1:14 AM, Carlo Medas <carlome...@gmail.com> wrote:

> Dears,
> we have a rpc.proto built inside our core framework, built as a DLL.
> Other protos contain extension to base message defined in rpc.proto,
> and they are built in separate and different executables.
> The MSVC linker compains for error since the RpcMessage class (defined
> in rpc.proto) and related extension factory methods are not declared
> with __declspec(dllexport) option when built in the DLL.
> Is there an option in the protoc compiler to make it generate the
> dllexport/dllimport options, exactly as you did for your Message base
> class with macro LIBPROTOBUF_EXPORT?
> Thanks in advance and keep up the amazing work,
> Carlo Medas
> >

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to