Issue 308 in protobuf: unresolved external symbol kEmptyString when linking protobuf as a dll.

755 views
Skip to first unread message

prot...@googlecode.com

unread,
Jun 30, 2011, 6:52:13 AM6/30/11
to prot...@googlegroups.com
Status: New
Owner: liuj...@google.com
Labels: Type-Defect Priority-Medium

New issue 308 by 0902h...@gmail.com: unresolved external symbol
kEmptyString when linking protobuf as a dll.
http://code.google.com/p/protobuf/issues/detail?id=308

What steps will reproduce the problem?
1.compile protobuf 2.4.1 as a dll.
2.generate *.pb.h/cc with protoc.exe and add to the vs2008 project.
3.set include path and lib path, compile, link.

What is the expected output? What do you see instead?
expected: no errors.
actual: unresolved external symbol "class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > const
google::protobuf::internal::kEmptyString"

What version of the product are you using? On what operating system?
2.4.1 on Windows 7.

Please provide any additional information below.
::google::protobuf::internal::kEmptyString is used in generated .cc files
and declared as "extern const ::std::string kEmptyString;" in
generated_message_util.h, but it is not exported.

prot...@googlecode.com

unread,
Jul 5, 2011, 1:44:16 AM7/5/11
to prot...@googlegroups.com
Updates:
Status: Accepted

Comment #1 on issue 308 by liuj...@google.com: unresolved external symbol

kEmptyString when linking protobuf as a dll.
http://code.google.com/p/protobuf/issues/detail?id=308

Could you please see the patch file to check if that fixes the issue?

Thanks.

Attachments:
export_empty_string.patch 461 bytes

prot...@googlecode.com

unread,
Jul 5, 2011, 1:21:05 PM7/5/11
to prot...@googlegroups.com

Comment #2 on issue 308 by liuj...@google.com: unresolved external symbol
kEmptyString when linking protobuf as a dll.
http://code.google.com/p/protobuf/issues/detail?id=308

Fixed in r401.

prot...@googlecode.com

unread,
Sep 28, 2012, 11:10:32 AM9/28/12
to prot...@googlegroups.com

Comment #3 on issue 308 by hxc0072...@gmail.com: unresolved external symbol
kEmptyString when linking protobuf as a dll.
http://code.google.com/p/protobuf/issues/detail?id=308


repro.

steps:
1. get the latest code from svn(20120928)
2. link protobuf as a dll
3. run the following code snippe

#include <stdio.h>
#include <google/protobuf/generated_message_util.h>

void main()
{
::std::string sts = ::google::protobuf::internal::kEmptyString;
}

expected:
build successful

acture:
error LNK2001: unresolved external symbol "class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > const google::protobuf::internal::kEmptyString"
(?kEmptyString@internal@protobuf@google@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@B)

prot...@googlecode.com

unread,
Sep 28, 2012, 11:12:13 AM9/28/12
to prot...@googlegroups.com

Comment #4 on issue 308 by hxc0072...@gmail.com: unresolved external symbol
kEmptyString when linking protobuf as a dll.
http://code.google.com/p/protobuf/issues/detail?id=308


repro.

steps:
1. get the latest code from svn(20120928)
2. link protobuf as a dll
3. run the following code snippet

#include <stdio.h>
#include <google/protobuf/generated_message_util.h>

void main()
{
::std::string sts = ::google::protobuf::internal::kEmptyString;
}

expected:
build successful

actual:

prot...@googlecode.com

unread,
Sep 28, 2012, 11:15:03 AM9/28/12
to prot...@googlegroups.com

Comment #5 on issue 308 by hxc0072...@gmail.com: unresolved external symbol
What version of the product are you using? On what operating system?
2012-09-28, win7 eng x86_64

prot...@googlecode.com

unread,
Sep 28, 2012, 11:18:56 AM9/28/12
to prot...@googlegroups.com

Comment #6 on issue 308 by hxc0072...@gmail.com: unresolved external symbol
2012-09-28, win7 eng x86_64,vc++2008/vc++2005

prot...@googlecode.com

unread,
Oct 26, 2012, 3:29:43 AM10/26/12
to prot...@googlegroups.com

Comment #7 on issue 308 by ppadev...@gmail.com: unresolved external symbol
kEmptyString when linking protobuf as a dll.
http://code.google.com/p/protobuf/issues/detail?id=308

I have the exact same problem. Even after applying patches 401 & 422, the
error is still there.

prot...@googlecode.com

unread,
Oct 26, 2012, 3:49:17 AM10/26/12
to prot...@googlegroups.com
Updates:
Owner: xiaof...@google.com

Comment #8 on issue 308 by liuj...@google.com: unresolved external symbol
kEmptyString when linking protobuf as a dll.
http://code.google.com/p/protobuf/issues/detail?id=308

(No comment was entered for this change.)

prot...@googlecode.com

unread,
Oct 31, 2012, 8:09:41 AM10/31/12
to prot...@googlegroups.com

Comment #9 on issue 308 by ppadev...@gmail.com: unresolved external symbol
kEmptyString when linking protobuf as a dll.
http://code.google.com/p/protobuf/issues/detail?id=308

The error was rather unexpected and easy to fix. The client application
should pass PROTOBUF_USE_DLLS explicitly, otherwise the symbols would not
get imported. I believe that the client should not do this and that this
should be the default behaviour but anyways... at least it works this way.

prot...@googlecode.com

unread,
Dec 3, 2012, 2:23:47 PM12/3/12
to prot...@googlegroups.com
Updates:
Status: Fixed

Comment #10 on issue 308 by xiaof...@google.com: unresolved external symbol
kEmptyString when linking protobuf as a dll.
http://code.google.com/p/protobuf/issues/detail?id=308

Marking this as fixed. Defining PROTOBUF_USE_DLLS in client applications
should fix the problem.

prot...@googlecode.com

unread,
Apr 17, 2013, 12:16:29 PM4/17/13
to prot...@googlegroups.com

Comment #11 on issue 308 by alastair.maw: unresolved external symbol
kEmptyString when linking protobuf as a dll.
http://code.google.com/p/protobuf/issues/detail?id=308

The Windows readme.txt file could do with updating to reflect this, if
someone with commit access has a spare minute.

This would save <one wasted hour of hunting around using dumpbin.exe
/EXPORT, etc> * <number of developers who stumble across this problem>

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

prot...@googlecode.com

unread,
Apr 17, 2013, 12:37:49 PM4/17/13
to prot...@googlegroups.com

Comment #12 on issue 308 by xiaof...@google.com: unresolved external symbol
kEmptyString when linking protobuf as a dll.
http://code.google.com/p/protobuf/issues/detail?id=308

The PROTOBUF_USE_DLLS macro is already mentioned in vsprojects/readme.txt:
3) When compiling your project, make sure to #define PROTOBUF_USE_DLLS.

prot...@googlecode.com

unread,
Aug 21, 2014, 1:50:50 PM8/21/14
to prot...@googlegroups.com

Comment #13 on issue 308 by jarek2ch...@gmail.com: unresolved external
symbol kEmptyString when linking protobuf as a dll.
http://code.google.com/p/protobuf/issues/detail?id=308

hi, i've sloved this issue by modyfing files
enerated_message_util.h/cc adding decoration LIBPROTOBUF_EXPORT:

double LIBPROTOBUF_EXPORT Infinity();
double LIBPROTOBUF_EXPORT NaN();
extern LIBPROTOBUF_EXPORT const ::std::string kEmptyString;

regards
jarek

jare...@yahoo.com (remove one 2)
Reply all
Reply to author
Forward
0 new messages