• VC2012编译protobuf出错处理


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

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

    下载完毕之后,就能够到protobufvsprojects文件夹下找到VC2008的project文件,然后打开project进行转换,这个没有问题。但在编译过程里会出现两个问题,第一个问题例如以下:

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

    1>  gtest_main.cc

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

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

    1>e:mygitprotobufgtestincludegtestgtest-printers.h(564): error C2977: 'std::tuple' : too many template arguments

    1>          c:program files (x86)microsoft visual studio 11.0vcincludeutility(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:protobufvsprojectsDebuglite-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)

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

  • 相关阅读:
    VMware+Centos 7如何配置NAT模式上网
    win 8.1 Your PC needs to be repaired修复过程
    oracle 11g 如何创建、修改、删除list-list组合分区
    关于博客园整理心得
    asp.net使用WebBrowser采集加载完毕后的页面
    解决webconfig中禁用掉ViewState造成服务器控件回传获取不到值问题
    asp.net 路由映射到ashx
    2019.3.17
    三星860 evo 250g 开启AHCI模式读写对比
    解决win10开机出现recovery there was a problem with a device connected to your pc
  • 原文地址:https://www.cnblogs.com/zhchoutai/p/6826645.html
Copyright © 2020-2023  润新知