external linkage for functions generated in protobuf headers

38 views
Skip to first unread message

Vinay Shivakumar

unread,
May 8, 2019, 2:29:57 AM5/8/19
to Protocol Buffers
Hi ,

I have a requirement where i need to use the generated functions like getters and setters from generated protobuf classes in different shared library other than where it is generated and built . all the funtions generated is "inlined" . because of this , i am getting undefined reference in shared library where i am using it . 

I have two questions :
1) is there any way to generate functions without inline ? is it recommended if possible ?
2) if inlining removal is not suggested , how do we reference the functions in different shared library ? some sort of wrapper for each getters and setters i want to use ?

Request your suggestions .

Thanks 
Vinay Shivakumar

Jie Luo

unread,
May 8, 2019, 1:12:02 PM5/8/19
to Protocol Buffers
What language of protobuf are you using?  We have public APIs for getters and setters. You can look into our web to see how to use them:

Adam Cozzette

unread,
May 9, 2019, 6:32:14 PM5/9/19
to Jie Luo, Vinay Shivakumar, Protocol Buffers
I haven't heard of any problems using the inline accessors with shared libraries before. Vinay, if you could post a small reproducible example then I could try to take a look. I don't think there is any way to disable the inlining.

From: Jie Luo <jie...@google.com>
Date: Thu, May 9, 2019 at 10:03 AM
To: Vinay Shivakumar, Adam Cozzette

+Adam Cozzette  for C++ generated code

On Wed, May 8, 2019 at 8:24 PM Vinay Shivakumar <vinh...@gmail.com> wrote:
Hi Jie,
Thanks for your reply.
Using C++ protobuf . Suppose i have message(class) as a member of another message(class)  . the function being generated to get an instance of the inner message is inline . I understand its left to compiler to consider the function for inline . Its not just the functions . even the classes generated in pb.h for corresponding message in proto.h having undefined reference . when i use  defualt visibility (__attribute__((visibility( default ))) ) for protobuf class manually and compile , symbol of the class appear in the .so shared library . This essentially means that protobuf classes are generated with hidden visibility . is it possible to have protobuf classes generated with default visibility so that they can be used across the shared 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/60889d0a-b599-4931-9850-c5dafe832b72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vinay Shivakumar

unread,
May 9, 2019, 11:11:53 PM5/9/19
to Adam Cozzette, Jie Luo, Protocol Buffers
Hi Adam,Jie,
I am really sorry . Issue was becasue the shared library was compiled with hidden visibiltiy . I have to take care of compiling protobuf classes compiled as part of shared library with default visibility . I would correct that . Sorry for the trouble .

Regards
Vinay Shivakumar
Reply all
Reply to author
Forward
0 new messages