3

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ファイルが含まれます。

4

1 に答える 1

1

将来の視聴者のために、コメントが回答に変換されます。

  1. MingW + MSYS パッケージをダウンロードしてインストールします。
  2. MingW のインストール フォルダ内の「msys」フォルダを「C:\msys」にコピーし、「C:\msys」内の「mingw」フォルダを削除します。
  3. 「C:\msys\etc\fstab」を「C:/QtSDK/mingw /mingw」に編集します
  4. protobuf ソースを「C:\msys\home\」にコピーします
  5. msys シェルを開き、"/home//protobuf" に移動します。
  6. http://eschew.wordpress.com/2009/09/20/building-protobuf-with-mingw-gcc-4-4-0/ - アイテム #2
  7. 「./configure --disable-shared」を実行します
  8. 「メイク」を実行
  9. 生成されたライブラリ ファイルを qt ライブラリ ディレクトリに手動でコピーします (ヘッダー ファイルも - ディレクトリ構造を維持します)。
于 2012-10-26T03:44:55.943 に答える