Protobuf - Refuses to link vs2013 or vs2015

2019-07-10 03:31发布

As the title states I cannot get protobuf to link successfully.

Here is the small test program. note the AddressBook class was generated usin gthe protoc compiler that was built when i compiled protobuf.Additionally, this proto file is part of googles protobuf examples that is included with the source.

#define PROTOBUF_USE_DLLS
#include <iostream>
#include "addressbook.pb.h"

#pragma comment(lib, "libprotocd.lib")
#pragma comment(lib, "libprotobufd.lib")
#pragma comment(lib, "libprotobuf-lited.lib")

int main(int argc, const char* argv[])
{
  tutorial::AddressBook ab;
  return 0;
}

Here are the errors I am receiving.

LNK2001: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const * const google::protobuf::internal::empty_string_" (?empty_string_@internal@protobuf@google@@3PEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@EB)

LNK2001: unresolved external symbol "__int64 google::protobuf::internal::empty_string_once_init_" (?empty_string_once_init_@internal@protobuf@google@@3_JA) 

Some assertions:

  1. Same code running on linux.. With the exception of -lprotoc -lprotobuf -lprotobuf-lite vs. the #pregma stuff
  2. Happens both in VS2013 and VS2015
  3. Tried both 3.0-Release and latest code from git. Same issue.
  4. I have tried this with both the debugtarget as well as the release (when using release removed trailing d from library name) target
  5. Made sure that both the additional include and library directories were set in the VS project. linker --> General --> Additional Library Directories is set to the place where the compiled .dll are located`

At this point I pretty much turned my attention to google to see what I could find. I ran across the following.

  1. 2015 not fully supported. It was old, but figured I would try vs2013
  2. protobuf dynamic linking Yes. When building with cmake I enabled shared library support and have the #define in my program
  3. disable inline expansion

Still, not able to progress past the above errors. Any help is greatly appreciated.

0条回答
登录 后发表回答