2016-04-01 27 views
1

protobufライブラリのリンク中に問題が発生しています。C++ Protobufエラーgoogle :: protobuf :: internal :: kEmptyStringエラー

/tmp/ccKgczB9.o:TickData.pb.cc:(.text+0x444): undefined reference to google::protobuf::internal::kEmptyString' /tmp/ccKgczB9.o:TickData.pb.cc:(.text+0x4a9): undefined reference to google::protobuf::internal::kEmptyString' /tmp/ccKgczB9.o:TickData.pb.cc:(.text+0x4c4): undefined reference to google::protobuf::internal::kEmptyString' /tmp/ccKgczB9.o:TickData.pb.cc:(.text+0x4de): undefined reference to google::protobuf::internal::kEmptyString' /tmp/ccKgczB9.o:TickData.pb.cc:(.text+0x502): undefined reference to google::protobuf::internal::kEmptyString' /tmp/ccKgczB9.o:TickData.pb.cc:(.text+0x53c): more undefined references to google::protobuf::internal::kEmptyString' follow /tmp/ccKgczB9.o:TickData.pb.cc:(.text$_ZN6google8protobuf8internal10WireFormat16VerifyUTF8StringEPKciNS2_9OperationE[__ZN6google8protobuf8internal10WireFormat16VerifyUTF8StringEPKciNS2_9OperationE]+0x1b): undefined reference to `google::protobuf::internal::WireFormat::VerifyUTF8StringFallback(char const*, int, google::protobuf::internal::WireFormat::Operation)' collect2: error: ld returned 1 exit status

使用される言語:C++ いるProtobufバージョン:2.6.1

私はすでに以下のリンク上のものを試してみましたが、それはうまくdoesntの:

Can't compile example from google protocol buffers

Undefined reference to google::protobuf::internal::empty_string_[abi:cxx11]

私はC++を初めて使用しています。私はまた、-std = C++ 11を使ってprotobufをコンパイルしようとしましたが、それと同じエラーです。

すべてのポインタが役立ちます。

+0

あなたが使用しているコンパイラのコマンドラインを表示してください。 (私の推測では、 '-lprotobuf'フラグがありません)。 –

+0

g ++ -g -L" /cygdrive/d/Softwares/protobuf-2.6.1/src/.libs "../proto/TickData.pb。 cc main.cpp -std = C++ 11 -lprotobuf – Abhishek

答えて

0

私は方法を見つけ出しました。

まず、g ++に-cオプションを使用し、.oファイルを生成する必要があります。次に、-oオプションを使用して実行可能ファイルを生成する必要があります。

以下に示すよう:

グラム++ -c -L/cygdriveの/ D /ワークスペース/ CPP /実践/ .LIBS/../proto/TickData.pb.cc main.cppに-std = C++ 11 -lprotobuf

グラム++ -g -Wall TickData.pb.o main.o -o MarketData.o -std = C++ 11 -lprotobuf