C++ 2010 Express Protobuf 编译错误

标签 c++ protocol-buffers

我在为 .lib 和 .dll 编译 protobuf 源代码 (2.4.1) 时遇到了很多麻烦。我在自述文件中逐字逐句地遵循了 google 的说明,但是 gtest 存在重大错误。虽然,我得到了 libprotobuf.lib、libprotobuf-lite.lib 和 libprotoc.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:\users\null\desktop\protobuf-2.4.1\protobuf-2.4.1\gtest\include\gtest\internal\gtest-tuple.h(745): error C3855: 'std::tr1::tuple_element': template parameter '_Idx' is incompatible with the declaration
2>c:\users\null\desktop\protobuf-2.4.1\protobuf-2.4.1\gtest\include\gtest\internal\gtest-tuple.h(757): error C2039: 'type' : is not a member of 'std::tr1::tuple_element'
2>          c:\users\null\desktop\protobuf-2.4.1\protobuf-2.4.1\gtest\include\gtest\internal\gtest-tuple.h(742) : see declaration of 'std::tr1::tuple_element'
2>c:\users\null\desktop\protobuf-2.4.1\protobuf-2.4.1\gtest\include\gtest\internal\gtest-tuple.h(757): error C2146: syntax error : missing ',' before identifier 'type'
2>c:\users\null\desktop\protobuf-2.4.1\protobuf-2.4.1\gtest\include\gtest\internal\gtest-tuple.h(757): error C2065: 'type' : undeclared identifier
2>c:\users\null\desktop\protobuf-2.4.1\protobuf-2.4.1\gtest\include\gtest\internal\gtest-tuple.h(761): error C2039: 'type' : is not a member of 'std::tr1::tuple_element'

最佳答案

我也遇到过。感谢 jahhaj 的指点。我尝试在 gtest-tuple.h 中将 tuple_element 更改为 tuple__element(双下划线)。它被使用了 3 次,其中一次在评论中。

然后所有内容在 Debug 和 Release 中都编译得很好,所有测试都成功运行。

编译期间出现了一些警告,但据我所知,它们要么是故意的,要么是 Visual Studio 的变幻莫测。

关于C++ 2010 Express Protobuf 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11822054/

相关文章:

c++ - 错误 : non-aggregate type 'vector<string>' cannot be initialized with an initializer list

c++ - 停留在 Trie 的迭代器实现上

c++ - 使用自定义构造函数初始化 C++ 类的实例作为 Objective C 类成员?

c++ - 如何遍历C++列表中固定数量的元素

c# - 为什么 IServerStreamWriter 不发送通知响应?

java - 如何解决 "protoc did not exit cleanly"?

javascript - 在本地主机上使用 TLS 的 Web gRPC

C++11 迭代交错数组?

linux - protobuf 和 Serialized Array/String/Ostream 提供的其他目标类型

sockets - Netty Detect传入请求是protobuf类型