Step 1, download and install: download the latest SourceCode project here in the https://code.google.com/p/protobuf/downloads/list, I use 2.5.0 version, download decompressed under the specified directory. [Plain] view plaincopyprint? Cd yourDir. /configure make check sudo make install cd yourDir. /configuremakemake checksudo make install where ,. /configure, which may cause problems (that is, my problems),. gcc does not exist because Xcodeb is not installed. the gcc command is available, but "C compiler is in use ..... no "(similar to this prompt), view config. log, the file cannot be found when the crt1.10.6.o link is displayed. The solution is to link a previous c. "stdio. h "file cannot find the above three reasons, the best way is: Xcode-> Preferences-> Downloads under Components, select to install Command Line Tools after installation, then execute the preceding three commands in sequence to complete the second step of installation. the proto configuration file is compiled into multiple code files ProtocolLogic. proto File
package lm; message helloworld { required int32 age = 1; required string name = 2; optional string phone = 3; } package lm;message helloworld{required int32 age = 1;required string name = 2;optional string phone = 3;}
Compile and copy to the project directory
protoc -I=./ --cpp_out=./code_out ProtocolLogic.proto cp ./code_out/ProtocolLogic.pb.cc ~/*****/ProtocolLogic.pb.cpp cp ./code_out/ProtocolLogic.pb.h ~/*****/ProtocBuffers/ protoc -I=./ --cpp_out=./code_out ProtocolLogic.protocp ./code_out/ProtocolLogic.pb.cc ~/*****/ProtocolLogic.pb.cppcp ./code_out/ProtocolLogic.pb.h ~/*****/ProtocBuffers/
Step 3: compile these files in the project this step is a little complicated a. Copy the unzipped directory to the protobuf-2.5.0/src/google directory to the libs directory under the cocos2d-x project. B. Copy config. h from the decompressed directory to the libs/google Directory, which is mainly placed in some macro definitions. No way, the code is referenced. C. delete multiple language files. The google/protobuf/compiler directory is used to compile multiple languages. delete d. delete all *** unittest. cc files are test cases (guessed by file name), deleted, and two folders named by tesst e. delete other files. There are still one or two errors during compilation. Delete the corresponding files. the cc file OK is compiled and run successfully.