Install the specified Protobuf version to the Mac-Protobuf2.6.1,

Source: Internet
Author: User

Install the specified Protobuf version to the Mac-Protobuf2.6.1,

Recently, Protobuf has been used in new projects to store data, and many pitfalls have been encountered during installation. On the internet, Protobuf has also been integrated into iOS systems, but it has many pitfalls.

Below is a summary of the installation process:

View official documents
Source code in the https://github.com/google/protobuf, if you do not want to compile their own get the latest version, you can download the official compilation of the various platforms,: Compile

Step 1: cd/Users/sddd/Downloads/protobuf-2.6.1

Step 2: Run./configure

Step 3: Run make

Step 4: Run make check

Step 5: Run make install

If you do not have permission, add sudo to the front.

Now you can install it successfully. You can view the forwarded blog on the project.

In the terminal protoc -- version

Next is how to compile a proto File

1: Open the terminal: cd to the folder where proto is stored.
2: Enter the command: protoc -- plugin =/usr/local/bin/protoc addressbook. proto -- cpp_out = "./" this is to generate the c ++. h. cc file.
3: Enter the command: protoc -- plugin =/usr/local/bin/protoc addressbook. proto -- objc_out = "./" this is to generate the oc. h. m file. If you want to install the latest version, there is a solution below 

First, open the terminal.

Brew-v

If notruby -e $(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)

Brew install automakebrew install libtoolbrew install protobuf is downloaded and installed using brew. Protobuf is what we want, and the other two are dependent libraries and after git clone https://github.com/alexeyxo/protobuf-objc.git is complete

Cd ~ /Protobuf-objc

./Autogen. sh

./Configure

~ /Protobuf-objc is actually the directory of the file just cloned.

./Configure may report an error, but don't worry, analyze the error information first

Configure: error:

ERROR: protobuf headers are required.

You must either install protobuf from google,

Or if you have it installed in a custom location

You must add'-imo-dedir' to CXXFLAGS

And '-llibdir' to LDFLAGS.

If you did not specify a prefix when installing

Protobuf, try

'./Configure CXXFLAGS =-I/usr/local/include LDFLAGS =-L/usr/local/lib'

In some 64-bit environments, try LDFLAGS =-L/usr/local/lib64.

Looking at it carefully, it is not difficult to find a solution provided by the terminal. I think this should be related to whether the system is 64-bit (I guess ).

./Configure CXXFLAGS =-I/usr/local/include LDFLAGS =-L/usr/local/lib

After the operation is passed,

Make

Make install

The generated plug-in is named protoc-gen-objc and will be installed in the/usr/local/bin/directory.

You can

Cd/usr/local/bin/

Ls-

According to my method, you can certainly see protoc-gen-objc.

Everything is ready. Let's test it.

Create a ProtoBuf folder on the desktop. Then

Cd ~ /Desktop/ProtoBuf

Protoc -- plugin =/usr/local/bin/protoc-gen-objc person. proto -- objc_out = ./

Protoc will automatically search for the plug-in named "protoc-gen-objc" under the/usr/local/bin/directory, compile the. proto file using the plug-in, and generate two files:

Person. pb. h

Person. pb. m

 

Recommended blogs:

 

Http://www.jianshu.com/p/d5642a7d1e10? Nomobile = yes

 

Http://www.jianshu.com/p/cbbb0bfd0bb6

 
 

 

Related Article

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.