链接错误,即使我包含了 headers 和库(即 self-compiled)

Linking errors even though I've included headers and library (which is self-compiled)

我已经尝试了几个小时让 protobuf 工作,但感觉我已经尝试了所有可以尝试的事情,但我仍然无法在没有这些错误的情况下实现 link:

LNK2019 unresolved external symbol "public: __thiscall tutorial::Person_PhoneNumber::Person_PhoneNumber(void)" (??0Person_PhoneNumber@tutorial@@QAE@XZ) referenced in function "public: static class tutorial::Person_PhoneNumber * __cdecl google::protobuf::Arena::Create<class tutorial::Person_PhoneNumber>(class google::protobuf::Arena *)" (??$Create@VPerson_PhoneNumber@tutorial@@@Arena@protobuf@google@@SAPAVPerson_PhoneNumber@tutorial@@PAV012@@Z) 
LNK2019 unresolved external symbol "public: __thiscall tutorial::Person::Person(void)" (??0Person@tutorial@@QAE@XZ) referenced in function "public: static class tutorial::Person * __cdecl google::protobuf::Arena::Create<class tutorial::Person>(class google::protobuf::Arena *)" (??$Create@VPerson@tutorial@@@Arena@protobuf@google@@SAPAVPerson@tutorial@@PAV012@@Z)
LNK2019 unresolved external symbol "public: __thiscall tutorial::AddressBook::AddressBook(void)" (??0AddressBook@tutorial@@QAE@XZ) referenced in function _main
LNK2019 unresolved external symbol "public: virtual __thiscall tutorial::AddressBook::~AddressBook(void)" (??1AddressBook@tutorial@@UAE@XZ) referenced in function _main    

我正在使用 MS Visual Studio 2015。库和 header 文件 包括在内(如果我重命名 .lib-file ,它抱怨找不到它)。

我已经尝试了 2.6.1 和 3.0.0b3(protoc 和 libprotobuf,self-compiled 和没有)。我自己编译了protoc,用那个编译了example.proto文件,还是编译不了protobuf自带的example。我已经在调试和发布模式下编译了我自己的项目和 protobuf,并且我已经或多或少地复制了 protobuf 自己的测试项目中的 every 设置到我自己的,但它没有'编译。

感觉好像我错过了一些超级简单的东西,但我已经用谷歌搜索了几个小时,但我找不到我做错了什么。

即使像下面这样的超级简单的文件也会产生同样的错误。

#include "example.pb.h"

int main()
{
    GOOGLE_PROTOBUF_VERIFY_VERSION;
    Example ex;
}

do/try还有什么?

当您在 example.proto 上 运行 protoc 时,它会生成两个文件:example.pb.hexample.pb.cc。您需要将 example.pb.cc 编译到您的程序中。