c++ - 为什么我不能将 gRPC 链接到我的静态库中?
问题描述
我已经编译了带有所有依赖项(Protobuf、a-arec 等)的 gRPC 1.23.0。
将我的.proto
文件翻译成*.grpc.pb.*
和*.pb.*
文件后,我将其添加到 VS 项目并成功将其编译为.exe
文件。
但是在我将Configuration type
属性切换到Dynamic library
or之后Static library
(我真的需要完全Static library
),它编译没有错误,但是在链接步骤中Build output
我看到 >2000 链接警告是这样的:
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
配置时出现。就它链接成功,但也有Release
链接警告。
我应该怎么做才能解决它?
解决方案
推荐阅读
- java - 在 jdk13 中展开地图构造函数
- node.js - 如何为节点控制器编写 Jest 单元测试
- eclipse - sbt eclipse 错误评估任务 scalaoptions 错误
- c# - 无法使用自动化 selenium c# 访问谷歌
- r - 在 R 中安装 dagitty 和 ggdag 包时出错
- c# - 从 Windows Service .net 应用程序发送 Win10 通知
- python - 使用来自另一个数据帧的信息制作新的数据帧
- swift - 无法通过通知发送 json 数据
- ios - 在视频上拉伸的贴纸和文字
- javascript - 如何从 JSON.parse(xhr.response) 获取内容