我试图通过Google使用协议缓冲区来实现应用程序的保存文件。生成的Protobuf代码崩溃应用程序
准备
一个简单的测试.proto文件已经创建,用于测试功能:
message LessonFile {
optional string creator = 1;
}
创建.pb.cc和.pb.h被纳入项目。 Lib和include目录在项目的属性中指定。
问题
运行时包括新生成的代码到项目成果的应用程序崩溃。
通过调试死机状态,它指出这个功能:
UnknownFieldSet::UnknownFieldSet()
: fields_(NULL) {} ---------here---------
而帧以上的几点:
LessonFile::LessonFile()
: ::google::protobuf::Message() { ---------here---------
SharedCtor();
}
调用堆栈:
google::protobuf::UnknownFieldSet::UnknownFieldSet (this=0x770e3cc3)
LessonFile (this=0xba64b30) protobuf_AddDesc_LessonFile_2eproto()
StaticDescriptorInitializer_LessonFile_2eproto (this=0x4bc108)
__static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) global constructors keyed to _Z38protobuf_AssignDesc_LessonFile_2eprotov()
__do_global_ctors()
__mingw_CRTStartup() WinMainCRTStartup()
其他信息
En环境:Netbeans; Windows7-64; Qt-4.8.1 + mingw,protobuf-2.4.1。
也有问题的Protobuf编译过程:化妆检查是不断失败,这个消息:
In file included from ./include/gtest/gtest-param-test.h:159:0, from ./include/gtest/gtest.h:59, from src/gtest.cc:34: ./include/gtest/internal/gtest-param-util-generated.h: In instantiation of ::operator testing::internal::ParamGenerator() const [with T = bool; T1 = bool; T2 = bool]>: ./include/gtest/gtest-param-test.h:1186:28:
required from here ./include/gtest/internal/gtest-param-util-generated.h:80:26: error: was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] In file included from ./include/gtest/gtest.h:59:0, from src/gtest.cc:34: ./include/gtest/gtest-param-test.h:288:58: note: testing::internal::ParamGenerator testing::ValuesIn(const Container&)> declared here, later in the translation unit
虽然库和protoc.exe成功编译和使安装创建包括目录和lib * .a/lib * .dll.a文件。
我有 - 完全相同的问题。在我的情况下,这是因为我编译libprotobuf时使用的是不同于QT的mingw版本。我使用QT Creator打包的mingw编译libprotobuf ...问题就消失了。不知道这是否适用于你,因为你不使用QT Creator ... –
我已经重新编译Protobuf,使用Madde shell(它包含在Qt中)。还使用了额外的配置参数:./configure --prefix =/c/QtSDK/mingw/ 虽然,结果是一样的 - 执行是faild,Protobuf无法管理* make check *。 此外,似乎应用程序退出(0xc0000005)上的错误代码被定义为“内存访问冲突”。也许有人知道这种类型的错误的somrthing。 –
我试图跟踪配置过程,似乎./configure正在使用C:/ mingw而不是C:/ QtSDK/mingw。两者的库都是不同的:4.7.x和4.4.0。有关如何强制它与QtSDK一起使用的建议? –