LNK2019 and LNK2001 problems in MSVS2008

1,852 views
Skip to first unread message

mohito

unread,
Mar 16, 2010, 4:43:01 PM3/16/10
to Protocol Buffers
Hi.

I use MSVS2008 and I have next problem:

I installed "protocol buffers" from "vsprojects" folder in Debug mode,
like it was recomended in readme.txt.
Next step I took example proto-file addressbook.proto and I had
compiled it by using proto.exe (that i had got above).
I created new solution and added in it next files: addressbook.pb.h,
addressbook.pb.cc, add_person.cc (from examples folder)

Solution comiles fine, but while linking process I have many errors
like this:

addressbook.pb.obj : error LNK2019: unresolved external symbol
"public: __thiscall
google::protobuf::internal::GeneratedMessageReflection::GeneratedMessageReflection(class
google::protobuf::Descriptor const *,class google::protobuf::Message
const *,int const * const,int,int,int,class
google::protobuf::DescriptorPool const *,class
google::protobuf::MessageFactory *,int)" (??
0GeneratedMessageReflection@internal@protobuf@google@@QAE@PBVDescriptor@23@PBVMessage@23@QBHHHHPBVDescriptorPool@23@PAVMessageFactory@23@H@Z)
referenced in function "void __cdecl
tutorial::protobuf_AssignDesc_addressbook_2eproto(void)" (?
protobuf_AssignDesc_addressbook_2eproto@tutorial@@YAXXZ)
addressbook.pb.obj : error LNK2019: unresolved external symbol
"public: static class google::protobuf::MessageFactory * __cdecl
google::protobuf::MessageFactory::generated_factory(void)" (?
generated_factory@MessageFactory@protobuf@google@@SAPAV123@XZ)
referenced in function "void __cdecl
tutorial::protobuf_AssignDesc_addressbook_2eproto(void)" (?
protobuf_AssignDesc_addressbook_2eproto@tutorial@@YAXXZ)
addressbook.pb.obj : error LNK2019: unresolved external symbol
"public: __thiscall
google::protobuf::internal::LogMessage::~LogMessage(void)" (??
1LogMessage@internal@protobuf@google@@QAE@XZ) referenced in function
"void __cdecl
tutorial::protobuf_AssignDesc_addressbook_2eproto(void)" (?
protobuf_AssignDesc_addressbook_2eproto@tutorial@@YAXXZ)


addressbook.pb.obj : error LNK2001: unresolved external symbol
"public: virtual class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > __thiscall
google::protobuf::Message::GetTypeName(void)const " (?
GetTypeName@Message@protobuf@google@@UBE?AV?$basic_string@DU?
$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)

total 69 errors.

I cannot solve this probelm.

Kenton Varda

unread,
Mar 16, 2010, 5:24:57 PM3/16/10
to mohito, Protocol Buffers
You need to link the example against libprotobuf.lib.


--
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.


mohito

unread,
Mar 17, 2010, 11:09:03 AM3/17/10
to Protocol Buffers
I had copied libprotobuf.lib, libprotobuf-lite.lib, libprotoc.lib
(this files was build in Debug mode) in my folder for additional
libraries (like "add\lib") and I had added path to this folder in MSVS
properties ("VC++ Directories").
I don't understand how I should link libprotobuf.lib in other way?

Kenton Varda

unread,
Mar 17, 2010, 12:53:44 PM3/17/10
to mohito, Protocol Buffers
You need to edit the project settings to tell it to actually link in libprotobuf.lib.  Simply putting it in a particular directory is not enough.  Please consult the MSVC docs.

You don't need libprotobuf-lite.lib (unless you're using optimize_for = LITE_RUNTIME) or libprotoc.lib (unless you're writing a code generator).


--

mohito

unread,
Mar 17, 2010, 4:44:00 PM3/17/10
to Protocol Buffers
Thanks for replies, I resolved this problem.
I had added this code in my project:

#pragma comment(lib, "libprotobuf.lib")

goldpal...@gmail.com

unread,
Mar 25, 2015, 1:50:52 PM3/25/15
to prot...@googlegroups.com
It's good. I follow your tip, complie to get libprotobuf.lib. Then I put the lib in the project folder, and add 
#pragma comment(lib, "libprotobuf.lib")
in my project. It worked. Thank you.
Reply all
Reply to author
Forward
0 new messages