liuguili@ubuntu:~/Desktop$ protoc./layer_primitive.proto --cpp_out=./
liuguili@ubuntu:~/Desktop$ ls
layer_primitive.pb.cc layer_primitive.proto
layer_primitive.pb.h layer_primitive.proto~
liuguili@ubuntu:~/Desktop$
建立test.c文件:
编译:
liuguili@ubuntu:~/Desktop$ g++ test.clayer_primitive.pb.cc -o ./test -I./-lprotobuf
liuguili@ubuntu:~/Desktop$ ls
layer_primitive.pb.cc layer_primitive.proto test
layer_primitive.pb.h layer_primitive.proto~ test.c
liuguili@ubuntu:~/Desktop$ ./test
100
liuguili@ubuntu:~/Desktop$
注:如果在原来的消息里是枚举值,那么可以在layer_primitive.pb.h找到相应的枚举定义赋值。