为什么我不能将gRPC链接到我的静态库中?

时间:2019-10-10 06:24:44

标签: c++ protocol-buffers grpc

我已经使用所有依赖项(Protobuf,a-arec等)编译了gRPC 1.23.0。

将我的.proto文件转换为*.grpc.pb.**.pb.*文件之后,我将其添加到VS项目中并成功地将其编译为.exe文件。

但是在我将Configuration type属性切换为Dynamic libraryStatic library(我确实确实需要Static library)之后,它进行了编译而没有错误,但是在{{1 }}我看到这样的> 2000个链接警告:

Build output

最后链接以错误结束:

1>grpc++_unsecure.lib(pb_encode.obj) : warning LNK4006: _pb_encode_submessage already defined in grpc++.lib(pb_encode.obj); second definition ignored
1>grpc++_unsecure.lib(pb_encode.obj) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
1>grpc++_unsecure.lib(codegen_init.obj) : warning LNK4006: "class grpc::CoreCodegenInterface * grpc::g_core_codegen_interface" (?g_core_codegen_interface@grpc@@3PAVCoreCodegenInterface@1@A) already defined in grpc++.lib(codegen_init.obj); second definition ignored
1>grpc++_unsecure.lib(codegen_init.obj) : warning LNK4006: "class grpc::GrpcLibraryInterface * grpc::g_glip" (?g_glip@grpc@@3PAVGrpcLibraryInterface@1@A) already defined in grpc++.lib(codegen_init.obj); second definition ignored
1>grpc++_unsecure.lib(codegen_init.obj) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
1>grpc_unsecure.lib(init.obj) : warning LNK4006: _grpc_register_plugin already defined in grpc.lib(init.obj); second definition ignored
1>grpc_unsecure.lib(init.obj) : warning LNK4006: _grpc_init already defined in grpc.lib(init.obj); second definition ignored
1>grpc_unsecure.lib(init.obj) : warning LNK4006: _grpc_shutdown already defined in grpc.lib(init.obj); second definition ignored
1>grpc_unsecure.lib(init.obj) : warning LNK4006: _grpc_is_initialized already defined in grpc.lib(init.obj); second definition ignored

仅对于1>libprotobufd.lib(version.res) : fatal error LNK1241: resource file libprotocd.lib(version.res) already specified 配置,会出现此错误。在Debug上,它可以成功链接,但也可以链接警告。

我应该怎么解决?

0 个答案:

没有答案