Windows 上的 gRPC C++ [英] gRPC C++ on Windows

查看:38
本文介绍了Windows 上的 gRPC C++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到现在为止,我已经尝试了 3 天,以找到如何在 Windows 上安装和使用 gRPC 没有运气.我使用的是 Visual Studio 2015,Win7 64 位.为了安全起见,我会一步一步地写我正在做的事情.这可能不是必需的,但我是 C++ 和 VS 的初学者,所以我完全不确定我是否正确:

I have been trying for 3 days by now to find how to install and use gRPC on windows with no luck. I am using Visual Studio 2015, Win7 64-bit. To be safe, I'll write step by step of what I am doing. It might not be necessary but I am a beginner with C++ and with VS so I am not at all sure I am doing it correctly:

(遵循指南 http://www.infopulse.com/博客/grpc-framework-by-google-tutorial/):

  • 从 git 中获取 gRPC,初始化子模块
  • 获取 protobuf 的 gmock 和 gtest(不在指南中,但在其他方面)不起作用)
  • 在 protobuf 上运行 cmake
  • 以发布模式在 Visual Studio 中构建 protobuf.sln(为解决方案的每个部分设置属性管理器 > C/C++ > 代码生成 > 运行时库 > /MDd)
  • 将 Release/文件夹复制到 protobuf/cmake/(而不是说明中的 Debug/- 这会给我 libprotobufd.lib 而不是 libprotobuf.lib 这是必需的)
  • 在 VS 中以 Release 模式构建 grpc/vsprojects/grpc_protoc_plugins.sln 并再次为解决方案的每个部分设置 属性管理器 > C/C++ > 代码生成 > 运行时库 > /MD
  • protoc.exe 从 protobuf/cmake/Release 复制到在上一步创建的 grpc/vsprojects/Release 中
  • 在调试模式下在 VS 中构建 grpc/vsprojects/grpc.sln(只有 grpc++ 部分,因为我在某处阅读并再次为解决方案的每个部分设置了属性管理器 > C/C++ > 代码生成> 运行库 > /MDd)
  • Get gRPC from git, init submodules
  • Get gmock and gtest for protobuf (not in the guide, but else it doesn't work)
  • Run cmake on protobuf
  • Build protobuf.sln in Visual Studio in Release mode (set for each part of the solution Property Manager > C/C++ > Code Generation > Runtime Library > /MDd)
  • Copy Release/ folder to protobuf/cmake/ (instead of Debug/ as in intructions - that would give me libprotobufd.lib instead of libprotobuf.lib which is required)
  • Build grpc/vsprojects/grpc_protoc_plugins.sln in VS also in Release mode and again set for each part of the solution Property Manager > C/C++ > Code Generation > Runtime Library > /MDd
  • Copy protoc.exe from protobuf/cmake/Release to grpc/vsprojects/Release, which was created in previous step
  • Build grpc/vsprojects/grpc.sln in VS in Debug mode (only the grpc++ part as I read somewhere and again set for each part of the solution Property Manager > C/C++ > Code Generation > Runtime Library > /MDd)

目前一切进展顺利.

  • 从示例文件夹中的 proto 生成 c 文件.我得到 helloworld.grpc.pb.cchelloworld.grpc.pb.hhelloworld.pb.cchelloworld.pb.h 并将它们全部移动到 grpc/examples/cpp/helloworld:

  • Generate c files from proto in example folder. I get helloworld.grpc.pb.cc, helloworld.grpc.pb.h, helloworld.pb.cc and helloworld.pb.h and move them all to grpc/examples/cpp/helloworld:

protoc --grpc_out=./hello_proto --plugin=protoc-gen-grpc=grpc_cpp_plugin.exe ../../examples/protos/helloworld.proto --proto_path=../../examples/protos

protoc --grpc_out=./hello_proto --plugin=protoc-gen-grpc=grpc_cpp_plugin.exe ../../examples/protos/helloworld.proto --proto_path=../../examples/protos

protoc --cpp_out=./hello_proto ../../examples/protos/helloworld.proto --proto_path=../../examples/protos

protoc --cpp_out=./hello_proto ../../examples/protos/helloworld.proto --proto_path=../../examples/protos

我在 VS 中保持 grpc.sln 打开并添加">新建项目"

I keep the grpc.sln open in VS and 'Add' > 'New Project'

当我尝试构建我的项目时报告错误,没有找到 gflags、gtest 和 libprotobuf.如果我找到所有内容并将它们移动到包含的文件夹中,则会出现以下错误:

When I try to build my project errors are reported with not finding gflags, gtest, and libprotobuf. If I find it all and move them to an included folder, then I get these errors:

    1>------ Build started: Project: greeter_client, Configuration: Debug Win32 ------
1>  greeter_client.cc
1>libprotobuf.lib(generated_message_util.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libprotobuf.lib(generated_message_util.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libprotobuf.lib(common.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libprotobuf.lib(common.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libprotobuf.lib(once.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libprotobuf.lib(once.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libprotobuf.lib(status.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libprotobuf.lib(status.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libprotobuf.lib(int128.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libprotobuf.lib(int128.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libprotobuf.lib(atomicops_internals_x86_msvc.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libprotobuf.lib(atomicops_internals_x86_msvc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>grpc++.lib(client_context.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>grpc++.lib(insecure_credentials.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>grpc++.lib(create_channel.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>grpc++.lib(credentials.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>grpc++.lib(create_channel_internal.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>grpc++.lib(channel_arguments.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>grpc++.lib(core_codegen.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>grpc++.lib(codegen_init.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>grpc++.lib(status.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: bool __thiscall std::ios_base::good(void)const " (?good@ios_base@std@@QBE_NXZ) already defined in grpc++.lib(channel_arguments.obj)
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: int __thiscall std::ios_base::flags(void)const " (?flags@ios_base@std@@QBEHXZ) already defined in grpc++.lib(channel_arguments.obj)
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: __int64 __thiscall std::ios_base::width(void)const " (?width@ios_base@std@@QBE_JXZ) already defined in grpc++.lib(channel_arguments.obj)
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: __int64 __thiscall std::ios_base::width(__int64)" (?width@ios_base@std@@QAE_J_J@Z) already defined in grpc++.lib(channel_arguments.obj)
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputc(char)" (?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z) already defined in grpc++.lib(channel_arguments.obj)
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: __int64 __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,__int64)" (?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE_JPBD_J@Z) already defined in grpc++.lib(channel_arguments.obj)
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" (?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in grpc++.lib(channel_arguments.obj)
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::tie(void)const " (?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ) already defined in grpc++.lib(channel_arguments.obj)
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: class std::basic_streambuf<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::rdbuf(void)const " (?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ) already defined in grpc++.lib(channel_arguments.obj)
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: char __thiscall std::basic_ios<char,struct std::char_traits<char> >::fill(void)const " (?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ) already defined in grpc++.lib(channel_arguments.obj)
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: char __thiscall std::basic_ios<char,struct std::char_traits<char> >::widen(char)const " (?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDD@Z) already defined in grpc++.lib(channel_arguments.obj)
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: void __thiscall std::basic_ostream<char,struct std::char_traits<char> >::_Osfx(void)" (?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in libprotobuf.lib(status.obj)
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" (?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ) already defined in libprotobuf.lib(status.obj)
1>libcpmt.lib(ios.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libcpmt.lib(ios.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libcpmt.lib(ios.obj) : error LNK2005: "public: static void __cdecl std::ios_base::_Addstd(class std::ios_base *)" (?_Addstd@ios_base@std@@SAXPAV12@@Z) already defined in msvcprtd.lib(MSVCP140D.dll)
1>libcpmt.lib(ios.obj) : error LNK2005: "private: static void __cdecl std::ios_base::_Ios_base_dtor(class std::ios_base *)" (?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z) already defined in msvcprtd.lib(MSVCP140D.dll)
1>libcpmt.lib(locale0.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libcpmt.lib(locale0.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libcpmt.lib(locale0.obj) : error LNK2005: "void __cdecl std::_Facet_Register(class std::_Facet_base *)" (?_Facet_Register@std@@YAXPAV_Facet_base@1@@Z) already defined in msvcprtd.lib(locale0_implib.obj)
1>libcpmt.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(void)" (?_Getgloballocale@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprtd.lib(MSVCP140D.dll)
1>libcpmt.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Init(bool)" (?_Init@locale@std@@CAPAV_Locimp@12@_N@Z) already defined in msvcprtd.lib(MSVCP140D.dll)
1>libcpmt.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,char const *)" (?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@PBD@Z) already defined in msvcprtd.lib(MSVCP140D.dll)
1>libcpmt.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_dtor(class std::_Locinfo *)" (?_Locinfo_dtor@_Locinfo@std@@SAXPAV12@@Z) already defined in msvcprtd.lib(MSVCP140D.dll)
1>libcpmt.lib(iosptrs.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libcpmt.lib(iosptrs.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libcpmt.lib(locale.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libcpmt.lib(locale.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libcpmt.lib(xlock.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libcpmt.lib(xlock.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in msvcprtd.lib(MSVCP140D.dll)
1>libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP140D.dll)
1>libcpmt.lib(xthrow.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libcpmt.lib(xthrow.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libcpmt.lib(xthrow.obj) : error LNK2005: "void __cdecl std::_Xbad_alloc(void)" (?_Xbad_alloc@std@@YAXXZ) already defined in msvcprtd.lib(MSVCP140D.dll)
1>libcpmt.lib(xthrow.obj) : error LNK2005: "void __cdecl std::_Xlength_error(char const *)" (?_Xlength_error@std@@YAXPBD@Z) already defined in msvcprtd.lib(MSVCP140D.dll)
1>libcpmt.lib(xthrow.obj) : error LNK2005: "void __cdecl std::_Xout_of_range(char const *)" (?_Xout_of_range@std@@YAXPBD@Z) already defined in msvcprtd.lib(MSVCP140D.dll)
1>libcpmt.lib(wlocale.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libcpmt.lib(wlocale.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libcpmt.lib(xlocale.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libcpmt.lib(xlocale.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libcpmt.lib(xdateord.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libcpmt.lib(xdateord.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libcpmt.lib(xwctomb.obj) : error LNK2005: __Getcvt already defined in msvcprtd.lib(MSVCP140D.dll)
1>libcpmt.lib(winapisupp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libcpmt.lib(winapisupp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libcpmt.lib(StlCompareStringA.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libcpmt.lib(StlCompareStringA.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libcpmt.lib(winapinls.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libcpmt.lib(winapinls.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libcpmt.lib(StlCompareStringW.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libcpmt.lib(StlCompareStringW.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libcpmt.lib(StlLCMapStringW.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libcpmt.lib(StlLCMapStringW.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>libcpmt.lib(StlLCMapStringA.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in greeter_client.obj
1>libcpmt.lib(StlLCMapStringA.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in greeter_client.obj
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>libeay32.lib(c_zlib.obj) : warning LNK4217: locally defined symbol _deflate imported in function _BIO_f_zlib
1>libeay32.lib(c_zlib.obj) : warning LNK4217: locally defined symbol _deflateEnd imported in function _BIO_f_zlib
1>libeay32.lib(c_zlib.obj) : warning LNK4217: locally defined symbol _inflate imported in function _BIO_f_zlib
1>libeay32.lib(c_zlib.obj) : warning LNK4217: locally defined symbol _inflateEnd imported in function _BIO_f_zlib
1>libeay32.lib(c_zlib.obj) : warning LNK4217: locally defined symbol _deflateInit_ imported in function _BIO_f_zlib
1>libeay32.lib(c_zlib.obj) : warning LNK4217: locally defined symbol _inflateInit_ imported in function _BIO_f_zlib
1>libeay32.lib(c_zlib.obj) : warning LNK4217: locally defined symbol _zError imported in function _zlib_zfree
1>greeter_client.obj : error LNK2019: unresolved external symbol "public: __thiscall helloworld::HelloRequest::HelloRequest(void)" (??0HelloRequest@helloworld@@QAE@XZ) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall GreeterClient::SayHello(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?SayHello@GreeterClient@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
1>greeter_client.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall helloworld::HelloRequest::~HelloRequest(void)" (??1HelloRequest@helloworld@@UAE@XZ) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall GreeterClient::SayHello(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?SayHello@GreeterClient@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
1>greeter_client.obj : error LNK2019: unresolved external symbol "public: __thiscall helloworld::HelloReply::HelloReply(void)" (??0HelloReply@helloworld@@QAE@XZ) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall GreeterClient::SayHello(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?SayHello@GreeterClient@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
1>greeter_client.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall helloworld::HelloReply::~HelloReply(void)" (??1HelloReply@helloworld@@UAE@XZ) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall GreeterClient::SayHello(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?SayHello@GreeterClient@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
1>greeter_client.obj : error LNK2019: unresolved external symbol "public: virtual class grpc::Status __thiscall helloworld::Greeter::Stub::SayHello(class grpc::ClientContext *,class helloworld::HelloRequest const &,class helloworld::HelloReply *)" (?SayHello@Stub@Greeter@helloworld@@UAE?AVStatus@grpc@@PAVClientContext@5@ABVHelloRequest@3@PAVHelloReply@3@@Z) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall GreeterClient::SayHello(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?SayHello@GreeterClient@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z)
1>greeter_client.obj : error LNK2019: unresolved external symbol "public: static class std::unique_ptr<class helloworld::Greeter::Stub,struct std::default_delete<class helloworld::Greeter::Stub> > __cdecl helloworld::Greeter::NewStub(class std::shared_ptr<class grpc::ChannelInterface> const &,class grpc::StubOptions const &)" (?NewStub@Greeter@helloworld@@SA?AV?$unique_ptr@VStub@Greeter@helloworld@@U?$default_delete@VStub@Greeter@helloworld@@@std@@@std@@ABV?$shared_ptr@VChannelInterface@grpc@@@4@ABVStubOptions@grpc@@@Z) referenced in function "public: __thiscall GreeterClient::GreeterClient(class std::shared_ptr<class grpc::Channel>)" (??0GreeterClient@@QAE@V?$shared_ptr@VChannel@grpc@@@std@@@Z)
1>grpc++.lib(create_channel_internal.obj) : error LNK2019: unresolved external symbol "public: virtual __thiscall grpc::Channel::~Channel(void)" (??1Channel@grpc@@UAE@XZ) referenced in function "public: virtual void * __thiscall grpc::Channel::`scalar deleting destructor'(unsigned int)" (??_GChannel@grpc@@UAEPAXI@Z)
1>grpc++.lib(create_channel_internal.obj) : error LNK2019: unresolved external symbol "private: __thiscall grpc::Channel::Channel(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct grpc_channel *)" (??0Channel@grpc@@AAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAUgrpc_channel@@@Z) referenced in function "class std::shared_ptr<class grpc::Channel> __cdecl grpc::CreateChannelInternal(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct grpc_channel *)" (?CreateChannelInternal@grpc@@YA?AV?$shared_ptr@VChannel@grpc@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@3@PAUgrpc_channel@@@Z)
1>C:\Tool\C++gRPC\grpc\vsprojects\\Debug\gflagsd.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'X86'
1>C:\Tool\C++gRPC\grpc\vsprojects\Debug\greeter_client.exe : fatal error LNK1120: 8 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

如果有人能提供解决方案,我将不胜感激.

If anyone could offer a solution, I will be grateful.

推荐答案

在各种错误中挣扎了很多天后,我在这里找到了准备安装的版本 https://github.com/plasticbox/grpc-windows 这似乎满足我的目的.我把它贴在这里,以防有人遇到类似情况.

After struggling with various errors for many days, I found ready-to-install version here https://github.com/plasticbox/grpc-windows which seems to work satisfactory for my purpose. I post it here in case anyone is in similar situation.

更新:2020 年 6 月

根据 GitHub 上的项目页面,该项目不再维护,因此该示例可能不再起作用:

According to the project page on GitHub the project is no longer maintained and therefore the example might not work any longer:

2019 年 5 月 注意:项目不再处于积极开发阶段,我绝对推荐使用 vcpkg

May 2019 NOTE: Project is no longer under active development, I definitely recommend using vcpkg

这篇关于Windows 上的 gRPC C++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆