C++2010 Express Protobuf编译错误
C++ 2010 Express Protobuf Compiling Errors
我在为.lib和.dlls编译protobuf源代码(2.4.1)时遇到了很多问题。我逐字逐句地遵循了自述中谷歌的指示,但gtest有重大错误。尽管我得到了libprotobuf.lib、libprotobuf-lite.lib和libprotocol.lib,但是gtest失败有关系吗?此外,我可以将libprotobuf编译到.dll中,但对于libprotobuf-lite.dll和libprotoc.dll,构建失败并出现错误。
我的问题是:我怎么还能在msvc++2010 express中使用protobuf进行编程。还有其他人执行它吗?
谢谢。
编辑::一些生成错误。。。
1>------ Build started: Project: libprotobuf, Configuration: Debug Win32 ------
2>------ Build started: Project: gtest, Configuration: Debug Win32 ------
3>------ Build started: Project: libprotobuf-lite, Configuration: Debug Win32 ------
2> gtest.cc
3> zero_copy_stream_impl_lite.cc
1> zero_copy_stream_impl_lite.cc
2>c:usersnulldesktopprotobuf-2.4.1protobuf-2.4.1gtestincludegtestinternalgtest-tuple.h(745): error C3855: 'std::tr1::tuple_element': template parameter '_Idx' is incompatible with the declaration
2>c:usersnulldesktopprotobuf-2.4.1protobuf-2.4.1gtestincludegtestinternalgtest-tuple.h(757): error C2039: 'type' : is not a member of 'std::tr1::tuple_element'
2> c:usersnulldesktopprotobuf-2.4.1protobuf-2.4.1gtestincludegtestinternalgtest-tuple.h(742) : see declaration of 'std::tr1::tuple_element'
2>c:usersnulldesktopprotobuf-2.4.1protobuf-2.4.1gtestincludegtestinternalgtest-tuple.h(757): error C2146: syntax error : missing ',' before identifier 'type'
2>c:usersnulldesktopprotobuf-2.4.1protobuf-2.4.1gtestincludegtestinternalgtest-tuple.h(757): error C2065: 'type' : undeclared identifier
2>c:usersnulldesktopprotobuf-2.4.1protobuf-2.4.1gtestincludegtestinternalgtest-tuple.h(761): error C2039: 'type' : is not a member of 'std::tr1::tuple_element'
我也有这个。感谢jahhaj的指点。我试着在gtest tuple.h中将tuple_element
更改为tuple__element
(双下划线)。它已经使用了3次,其中一次是在注释中
然后,在调试和发布中,一切都编译得很好,所有测试都成功运行
在编译过程中出现了一些警告,但据我所知,这些警告要么是Visual Studio故意的,要么是变幻莫测的。
我可以告诉你问题是什么,如果不是解决方案的话。gtest头文件之一是定义一个名为std::tr1::tuple_element
的类。MS定义了一个完全相同名称的不同类,您可以在<实用程序>头文件。除了等待谷歌这么做,我看不出有任何方法可以解决这个问题。这是一个已经向他们报告的问题。
或者,您可以下载预编译的Windows版本
我也遇到过这个问题。由于我使用的是Visual Studio 2010
,所以实际上定义了std::tr1::tuple
。
阅读README文件中的选择TR1元组库部分,我将尝试使用编译器标志-DGTEST_USE_OWN_TR1_TUPLE=0
,或者在Visual Studio中仅为GTEST_USE_OWN_TR1_TUPLE=0
。
这解决了我的问题,因为这个元组已经在VisualStudio2010中提供的TR1功能中定义了。
- 用MacOS Mojave编译C++:致命错误:mpi.h:没有这样的文件或目录
- std::is_base_of表示ctor编译错误
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 在没有定义返回类型的函数中返回布尔值,并将结果保存在无错误的char编译中-为什么
- Qt5:使用QCommandLineParser类时出现奇怪的编译错误
- Qt Cmake 错误编译"GuiSupportQt not found"
- Opengl 精度转换错误编译错误 E0415
- 库将ARM架构错误编译为架构X64
- RT 音频 Mac 错误 g++ 编译错误
- 错误编译Boost.log
- 错误编译QT创建者 / QT窗口小部件示例
- 错误编译MIPS32
- Visual Studio 2013 中的错误(编译和运行代码)
- 链接错误编译qt项目在visual 2010
- 无法用模板错误编译nsgmls
- 奇怪的错误.编译失败
- 如果有人调用c++中的方法,则强制错误(编译时)
- 来自autoconf测试的错误编译命令
- 时间限制超出错误C++编译
- SFML 2.3 和 CodeBlocks 错误编译