mac下怎么装protobuf-c-compiler

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mac下怎么装protobuf-c-compiler相关的知识,希望对你有一定的参考价值。

参考技术A 首先是怎么安装Protobuf。 来自https://github.com/alexeyxo/protobuf-objc的文档。

打开终端!

brew -v

查看你的mac里面有没有装brew。brew是mac os里面,类似于ubuntu的apt-get的功能,都可以直接在终端输入命令然后安装程序。-v自然就是版本version的意思

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

这一句半懂不懂,大概就是利用curl工具访问那个url,然后在ruby环境下载安装brew

建议先去Homebrew官网找最新的下载地址

brew install automake

brew install libtool

brew install protobuf

就是利用brew下载安装了。protobuf就是我们想要的,另外两个是依赖库

git clone https://github.com/alexeyxo/protobuf-objc.git

./build.sh

从github下载protobuf-objc这个工程,build脚本里面做的是编译。

我建议不要用 ./build.sh ,我安装过程中发现未知错误最终没有进行下去。哎,好失败。懂脚本的朋友可以尝试下。

到此,我们先得感谢 http://www.2cto.com/kf/201503/382440.html的文章作者。点开链接的朋友会发现,这都什么吗,明显照抄人家的。。。

我只能说,该作者前半部分解释的非常好,我是超越不了了,只能完全借用了。其实说白了,就是懒。言归正传:

当我们 git clone https://github.com/alexeyxo/protobuf-objc.git 完成后,

cd ~/protobuf-objc

./autogen.sh

./configure

~/protobuf-objc其实就是刚刚clone的文件目录

进行./configure 可能会报错,不过别着急,先分析错误信息

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 '-Iincludedir' 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.

仔细看,不难发现终端给出了解决办法,我想这应该是跟系统是不是64位有关吧(个人猜测)。

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

运行通过后,

make

make install

以上是关于mac下怎么装protobuf-c-compiler的主要内容,如果未能解决你的问题,请参考以下文章

苹果电脑怎么重新装系统

mac抹掉磁盘重装系统怎么操作?

苹果笔记本怎么重新键盘安装系统?

mac的虚拟机怎么启动

怎么装Clover完美启动双系统

macbook pro win7系统下,摄像头驱动坏了,怎么弄啊?急啊!!