GoogleのProtocolBuffersを使用して、アプリケーションの保存ファイルを実装しようとしています。
準備
機能をテストするために、簡単なテスト.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 ()
追加情報
環境:Netbeans; Windows7-64; Qt-4.8.1 + mingw、protobuf-2.4.1。
また、Protobufのコンパイルプロセスに問題がありました。次のメッセージでmakecheckが常に失敗します。
./include/gtest/gtest-param-test.h:159:0、./include/gtest/gtest.h:59、src/gtest.cc:34からインクルードされたファイル:./ include / gtest / internal / gtest-param-util-generated.h::: operator tests :: internal :: ParamGenerator()const [with T=bool;のインスタンス化 T1=ブール; T2 = bool]>:./include/gtest/gtest-param-test.h:1186:28:
ここから必要です./include/gtest/internal/gtest-param-util-generated.h:80:26:エラー:このスコープで宣言されておらず、インスタンス化の時点で引数依存のルックアップによって宣言が見つかりませんでした[ -fpermissive] ./include/gtest/gtest.h:59:0、src/gtest.cc:34からインクルードされたファイル:./ include / gtest / gtest-param-test.h:288:58:注:テスト::internal:: ParamGeneratortesting :: ValuesIn(const Container&)>ここで宣言され、後で翻訳ユニットで宣言されます
ただし、ライブラリとprotoc.exeは正常にコンパイルされ、インストールが作成され、ディレクトリとlib * .a / lib*.dll.aファイルが含まれます。