Protobuf - Refuses to link vs2013 or vs2015

匿名 (未验证) 提交于 2019-12-03 01:00:01

问题:

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!