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

查看:94
本文介绍了链接到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

Error 1 error C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' s:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility

Error 1 error C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' s:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility

我尝试在其他命令行参数中使用-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 detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj S:\eiogit3\misc-projs\mapload\mapload\libprotobufd.lib(common.obj)

推荐答案

这与 VStudio C(和C ++)运行时库( VCRTLib UCRT -检查

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天全站免登陆