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
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
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?
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)
Works great. Thanks a lot.
Comment #5 on issue 177 by jas...@google.com: undefined symbol in shared
lib on Ubuntu 10.04
http://code.google.com/p/protobuf/issues/detail?id=177
(No comment was entered for this change.)
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.