C++
$ SRC_DIR=`pwd` $ ../protobuf-2.4.1/src/protoc -I=$SRC_DIR --cpp_out=. $SRC_DIR/addressbook.proto $ g++ addressbook.pb.cc writeMsg.cpp -o writeMsg -I ../protobuf-2.4.1/src -L ../protobuf-2.4.1/src/.libs/ -l protobuf $ export LD_LIBRARY_PATH=../protobuf-2.4.1/src/.libs $ ./writeMsg address.txt $ g++ addressbook.pb.cc readMsg.cpp -o readMsg -I ../protobuf-2.4.1/src -L ../protobuf-2.4.1/src/.libs/ -l protobuf $ ./readMsg address.txt Person ID: 12 Name: me E-mail address: me@t.net Home phone #: 123533333 $ ls addressbook.pb.cc addressbook.proto readMsg writeMsg addressbook.pb.h address.txt readMsg.cpp writeMsg.cpp
Java
../protobuf-2.4.1/src/protoc --java_out=../protobuf-2.4.1/java/src/main/java -I ../protobuf-2.4.1/src ../protobuf-2.4.1/src/google/protobuf/descriptor.proto cd ../protobuf-2.4.1/java/src/main/java/com/google/protobuf javac * cd - export CLASSPATH=../protobuf-2.4.1/java/src/main/java:. javac com/example/tutorial/Addressbook.java javac writeMsg.java java AddPerson javac readMsg.java java ListPeople ../c++/address.txt Person ID: 12 Name: me E-mail address: me@t.net Home phone #: 123533333
No comments:
Post a Comment