Application of protocol buffers in cocos2d-x Engineering

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.