0
我想原始解码protobuf二进制文件。我从源代码安装了谷歌protobuf库https://github.com/google/protobuf 我能够使用命令protoc --decode_raw <encodedfile>
来使用命令行解码原始protobuf二进制文件。我希望能够使用C++库以编程方式执行此操作。类似于文档中以下示例的内容。如何编译谷歌Protobuf命令行界面编译
但是尝试编译一段简单的代码不起作用。
#include <iostream>
#include <fstream>
#include <string>
#include <google/protobuf/compiler/command_line_interface.h>
using namespace google::protobuf::compiler;
using namespace std;
int main(int argc, char* argv[]) {
google::protobuf::compiler::CommandLineInterface cli_;
cerr << "Compiled And Run" << endl;
}
编译命令
c++ my_program.cc -o my_program -pthread -I/usr/local/include -pthread -L/usr/local/lib -lprotobuf -lpthread
我看到下面的错误
my_program.cc:(.text+0x24): undefined reference to `google::protobuf::compiler::CommandLineInterface::CommandLineInterface()'
my_program.cc:(.text+0x4f): undefined reference to `google::protobuf::compiler::CommandLineInterface::~CommandLineInterface()'
my_program.cc:(.text+0x70): undefined reference to `google::protobuf::compiler::CommandLineInterface::~CommandLineInterface()'
欣赏任何帮助。
您是否构建了protobuf库?使用[此处]的步骤(https://github.com/google/protobuf/tree/master/src)。 – Steeve