VC2012编译protobuf出错处理

近来要学习protobuf的协议生成,需要从网上下载它的代码,从这个SVN地址下载:

http://protobuf.googlecode.com/svn/trunk

下载完成之后,就可以到protobuf\vsprojects目录下找到VC2008的工程文件,然后打开工程进行转换,这个没有问题。但在编译过程里会出现两个问题,第一个问题如下:

1>------ Build started: Project: gtest_main, Configuration: Debug Win32 ------

1>  gtest_main.cc

1>e:\protobuf\gtest\include\gtest\gtest-printers.h(556): error C2977: 'std::tuple' : too many template arguments

1>          c:\program files (x86)\microsoft visual studio 11.0\vc\include\utility(73) : see declaration of 'std::tuple'

1>e:\my\git\protobuf\gtest\include\gtest\gtest-printers.h(564): error C2977: 'std::tuple' : too many template arguments

1>          c:\program files (x86)\microsoft visual studio 11.0\vc\include\utility(73) : see declaration of 'std::tuple'

在这里由于使用std::tuple,并且使用的个数达到10个,因此编译提示上面的出错。只需要把std;;tuple里的个数定义为10个即可。更简单的方法是打开解决方案资源管理器,右键打开项目属性,在C/C++ --> “预处理器”--> “预处理定义中增加以下行即可:
_VARIADIC_MAX=10

VC2012_VARIADIC_MAX默认定义为5,因此不支持5个以上的参数输入,而导致出错。当然这样修改之后,编译时会多占用一点内存。

第二个问题如下:

3>------ Build started: Project: lite-test, Configuration: Debug Win32 ------

2>test_plugin.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification

2>gtestd.lib(gtest-all.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in test_plugin.obj

3>  lite-test.vcxproj -> E:\protobuf\vsprojects\Debug\lite-test.exe

2>msvcprtd.lib(MSVCP110D.dll) : error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in gtestd.lib(gtest-all.obj)

出现这个问题原因是工程在转换过程中,会有一些工程使用MD编译选项,有一些工程使用MTD编译选项,导致静态和动态连接MSVC的连接库有冲突。默认全部工程改变MTMTD编译,即可以解决。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

caimouse

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值