-2
私はgccでubuntu 16.04を実行しています。gccのprotobufコンパイルの問題
g++ -m64 -Wl,-O1 -L/usr/lib/x86_64-linux-gnu /usr/local/lib/libprotobuf.a my_messages.pb.cc q.cpp -lpthread
protoc --version
リターン:
私q.ccp
ファイルがコンパイルに使用
#include <my_messages.pb.h>
int main(int argc, char **argv)
{
google::protobuf::MyMessage* logged_msg_;
return 0;
}
コマンドである2.2.0
gccが--version
gcc (Ubuntu 4.8.5-4ubuntu2) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
コンパイルエラーが
undefined reference to `google::protobuf::internal::ExtensionSet::Clear()
で始まり、プロトコルバッファのすべての機能のために未定義の参照エラーが発生します。
libprotobuf.aは、必要な他のオブジェクトファイルの後ろに置いてください。 -lオプションの引数にしてはいけませんか? –