Protobuf - 拒绝链接vs2013或vs2015

时间:2016-09-01 20:13:30

标签: c++ visual-studio visual-studio-2013 protocol-buffers

正如标题所述,我无法protobuf成功链接。

这是一个小型测试程序。请注意AddressBook类是在我编译protobuf时生成的protoc编译器中生成的。此外,此proto文件是源代码中包含的googles protobuf示例的一部分。

#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;
}

以下是我收到的错误。

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) 

一些断言:

  1. 在linux上运行相同的代码.. 除了-lprotoc -lprotobuf -lprotobuf-lite与#pregma stuff
  2. 之外
  3. 在VS2013和VS2015中都会发生
  4. 尝试了3.0版本和git的最新代码。同样的问题。
  5. 我已经使用debug目标和release(当使用版本从库名称中删除尾随d时)尝试了此目标
  6. 确保在VS项目中设置了其他includelibrary目录。 linker --> General --> Additional Library Directories设置为已编译的.dll所在的位置
  7. 此时我几乎把注意力转向谷歌,看看我能找到什么。我遇到了以下情况。

    1. 2015 not fully supported。它太老了,但我想我会尝试vs2013
    2. protobuf dynamic linking是的。使用cmake构建时,我启用了共享库支持,并在程序中使用#define
    3. disable inline expansion
    4. 仍然无法超越上述错误。非常感谢任何帮助。

0 个答案:

没有答案
相关问题