Issue 177 in protobuf: undefined symbol in shared lib on Ubuntu 10.04

1,712 views
Skip to first unread message

prot...@googlecode.com

unread,
Apr 6, 2010, 5:31:29 PM4/6/10
to prot...@googlegroups.com
Status: New
Owner: ken...@google.com
Labels: Type-Defect Priority-Medium

New issue 177 by othy74: undefined symbol in shared lib on Ubuntu 10.04
http://code.google.com/p/protobuf/issues/detail?id=177

What steps will reproduce the problem?
1. I use protoc (--cpp_out=) then build my simple cpp shared lib
2. At runtime: undefined symbol: _ZNK6google8protobuf7Message11GetTypeNameEv

What version of the product are you using? On what operating system?
Default protobuf (2.2.0 I think) on Ubuntu 10.04

One person was able to fix this same issue on opensuse it seems:
http://forum.compiz.org/viewtopic.php?f=86&t=12257

There is no libprotobuf.so.4 in my /usr/lib/.


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

prot...@googlecode.com

unread,
Apr 6, 2010, 5:53:40 PM4/6/10
to prot...@googlegroups.com

Comment #1 on issue 177 by jas...@google.com: undefined symbol in shared

It sounds like you aren't linking against libprotobuf when compiling the
generated
code from your protoc command. Have you followed the instructions in the
README.txt?
http://code.google.com/p/protobuf/source/browse/trunk/README.txt

prot...@googlecode.com

unread,
Apr 6, 2010, 7:16:05 PM4/6/10
to prot...@googlegroups.com

Comment #2 on issue 177 by othy74: undefined symbol in shared lib on Ubuntu
10.04
http://code.google.com/p/protobuf/issues/detail?id=177

I was linking against libprotobuf-lite. Linking libprotobuf does indeed fix
the
runtime issue. Thanks! But now it's huge. My binary used to be 23 KB. After
including
the generated pb.cc it went to 100 KB. When linking libprotobuf-lite: 352
KB. And with
the full libprotobuf: 4458 KB. And my proto source file is only like 500
bytes. Is
this expected?

Are you advising the installation of protobuf from source, rather than
using the
default system packages?

prot...@googlecode.com

unread,
Apr 6, 2010, 7:37:39 PM4/6/10
to prot...@googlegroups.com

Comment #3 on issue 177 by jas...@google.com: undefined symbol in shared

If you want to use the lite runtime, you need to make sure that your .proto
file
includes
option optimize_for = LITE_RUNTIME;
Otherwise, the generated code will make use of features that are not in the
lite
library (producing errors like the one you saw about a missing symbol)

I don't recall the exact sizes of the libraries but that sounds about
right. The full
library is about 10x larger than the lite one.

Using system packages should be fine. (although I don't know anything
about these -
I believe the packages are maintained by third parties and might not be
kept up to
date)

prot...@googlecode.com

unread,
Apr 6, 2010, 8:21:32 PM4/6/10
to prot...@googlegroups.com

Comment #4 on issue 177 by othy74: undefined symbol in shared lib on Ubuntu
10.04
http://code.google.com/p/protobuf/issues/detail?id=177

Works great. Thanks a lot.

prot...@googlecode.com

unread,
Apr 7, 2010, 3:19:08 PM4/7/10
to prot...@googlegroups.com
Updates:
Status: WorkingAsIntended
Owner: jas...@google.com

Comment #5 on issue 177 by jas...@google.com: undefined symbol in shared

(No comment was entered for this change.)

prot...@googlecode.com

unread,
Apr 7, 2010, 8:57:27 PM4/7/10
to prot...@googlegroups.com

Comment #6 on issue 177 by ken...@google.com: undefined symbol in shared

Note that you can use the "strip" command to remove unnecessary debug
symbols and
other stuff from the binary, which may make it significantly smaller.

Also, it sounds like you are statically linking against libprotobuf. If you
dynamically link instead, your binary will remain small -- only the dynamic
library
needs to be large.

4MB sounds overly large; I would have expected more like 1MB from linking
libprotobuf. But it depends on a lot of factors.

prot...@googlecode.com

unread,
Apr 8, 2010, 7:09:11 PM4/8/10
to prot...@googlegroups.com

Comment #7 on issue 177 by othy74: undefined symbol in shared lib on Ubuntu
10.04
http://code.google.com/p/protobuf/issues/detail?id=177

My binary after optimize_for LITE = 450 KB.
And after strip --strip-debug = 194 KB. I'm dynamically linking.
But best of all: it's moving my objects over to Java and back.


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.

Reply all
Reply to author
Forward
0 new messages