链接到 MS Visual C 上的 protobuf 3 时出错 [英] Errors when linking to protobuf 3 on MS Visual C

查看:29
本文介绍了链接到 MS Visual C 上的 protobuf 3 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Studio 2013 上遇到过,但可以在任何版本中重现.

Encountered on Visual Studio 2013, but it's reproducible with any version.

我从 github 克隆了协议缓冲区库,在其上运行了 CMake-gui(我将所有内容都保留为默认值,所以它是静态版本),只构建了 libprotobuf(其他项目由于某种原因失败,cmd.exe 错误,可能有与测试有关,但 libprotobuf 构建良好).

I cloned the protocol buffer library from github, ran CMake-gui on it (I left everything to default, so it's the static version), only built libprotobuf (other project failed for some reason, cmd.exe error, might have something to do with tests, but libprotobuf builds fine).

我的项目使用在 mapbox 矢量切片规范的 github 上找到的 .proto 文件生成的标头.

My project uses headers generated with the .proto file found on the mapbox vector tiles spec's github.

当我链接时,我首先遇到这个错误

When I link, I first have this error

错误 1 ​​错误 C4996:'std::_Copy_impl':带有可能不安全的参数的函数调用 - 此调用依赖于调用者来检查传递的值是否正确.要禁用此警告,请使用 -D_SCL_SECURE_NO_WARNINGS.请参阅有关如何使用 Visual C++ 'Checked Iterators' s:program files (x86)microsoft visual studio 12.0vcincludexutility 的文档

我尝试在其他命令行参数中使用 -D_SCL_SECURE_NO_WARNINGS 禁用它,但随后出现了其他错误:

I tried disabling it with -D_SCL_SECURE_NO_WARNINGS in additional command line arguments, but then I have other errors:

Error 1 error LNK2038: mismatch detection for 'RuntimeLibrary': value 'MTd_StaticDebug' 与 main.obj S:eiogit3misc-projsmaploadmaploadlibprotobufd.lib 中的值 'MDd_DynamicDebug' 不匹配(common.obj)

推荐答案

VStudio C(和 C++)运行时库 (VCRTLibUCRT - 检查

It's a mismatch of how the VStudio C (and C++) RunTime Library (VCRTLib or UCRT - check [SO]: How to circumvent Windows Universal CRT headers dependency on vcruntime.h (@CristiFati's answer)) is used by your project and by libprotobuf project. Let me detail:

假设有一些 C (C++) 代码.该代码的目的是运行.比可以实现的:

Let's say there's some C (C++) code. The purpose of that code is to be run. Than can be achieved:

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