mac 上protobuf-2.6.0安裝步驟

注:參考  http://www.cnblogs.com/yuhan-TB/p/4629362.html


我自己的brew安裝踩坑了~ 所以就採取了跟Ubuntu下相似的安裝方式,這裏做一下筆記。

1.  git 上 https://github.com/google/protobuf下載tag v 2.6.0的代碼。解壓縮。

2. cd protobuf-2.6.0

3.網上說 ./configure 但是報沒有這個命令。但是裏面有autogen.sh的腳本。運行sudo ./autogen.sh, 發現出錯了。按參考的博客


sudo brew automake

sudo brew libtool 

sudo brew autoconf

錯誤,錯誤信息表示沒有automake,libtool.於是自己就手動安裝了。

這裏參考了這篇博客(http://blog.sina.com.cn/s/blog_586c261a0101jil1.html)

curl -O http://mirrors.kernel.org/gnu/m4/m4-1.4.13.tar.gz
tar -xzvf m4-1.4.13.tar.gz
cd m4-1.4.13
./configure –prefix=/usr/local
make
sudo make install



cd ..
curl -O http://mirrors.kernel.org/gnu/autoconf/autoconf-2.65.tar.gz
tar -xzvf autoconf-2.65.tar.gz
cd autoconf-2.65
./configure --prefix=/usr/local
make
sudo make install


cd ..
curl -O http://mirrors.kernel.org/gnu/automake/automake-1.11.tar.gz
tar xzvf automake-1.11.tar.gz
cd automake-1.11
./configure --prefix=/usr/local
make
sudo make install


cd ..
curl -O http://mirrors.kernel.org/gnu/libtool/libtool-2.2.6b.tar.gz
tar xzvf libtool-2.2.6b.tar.gz
cd libtool-2.2.6b
./configure --prefix=/usr/local
make

sudo make install


4.這些文件安裝完成之後,在

./configure

make

make check (檢查是否通過)


我在make check的時候報錯了。錯誤如下:

Making lib/libgtest.a lib/libgtest_main.a in gtest
depbase=`echo src/gtest-all.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
    /bin/sh ./libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I./build-aux  -I. -I./include  -D_THREAD_SAFE  -DGTEST_HAS_PTHREAD=1 -g -DNDEBUG -MT src/gtest-all.lo -MD -MP -MF $depbase.Tpo -c -o src/gtest-all.lo src/gtest-all.cc &&\
    mv -f $depbase.Tpo $depbase.Plo
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I./build-aux -I. -I./include -D_THREAD_SAFE -DGTEST_HAS_PTHREAD=1 -g -DNDEBUG -MT src/gtest-all.lo -MD -MP -MF src/.deps/gtest-all.Tpo -c src/gtest-all.cc  -fno-common -DPIC -o src/.libs/gtest-all.o
In file included from src/gtest-all.cc:39:
In file included from ./include/gtest/gtest.h:57:
In file included from ./include/gtest/internal/gtest-internal.h:40:
./include/gtest/internal/gtest-port.h:449:10: fatal error: 'tr1/tuple' file not found
#include <tr1/tuple>  // NOLINT
         ^
1 error generated.
make[3]: *** [src/gtest-all.lo] Error 1
make[2]: *** [check-local] Error 2
make[1]: *** [check-am] Error 2
make: *** [check-recursive] Error 1
解決方案: ./configure CPPFLAGS=-DGTEST_USE_OWN_TR1_TUPLE=1 

5. make install

我在make install 的時候報錯了

錯誤信息:

Making install in .
make[2]: Nothing to be done for `install-exec-am'.
test -z "/usr/local/lib/pkgconfig" || ./install-sh -c -d "/usr/local/lib/pkgconfig"
mkdir: /usr/local/lib/pkgconfig: Permission denied
make[2]: *** [install-pkgconfigDATA] Error 1
make[1]: *** [install-am] Error 2


是因爲沒有安裝這個包pkgconfig文件,但是自己下載安裝,卻又報錯誤,錯誤信息如下。但是這個解壓命令解壓其他的壓縮文件是可以的。唯獨這個文件不可以(暫時沒搞明白爲什麼)。


➜  ~ curl http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz -o pkg-config-0.28.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   365  100   365    0     0    349      0  0:00:01  0:00:01 --:--:--   349
➜  ~
➜  ~ tar -xf pkg-config-0.28.tar.gz
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.

6 .最後不顧錯誤提醒。看到了Permission denied。因此 sudo make install  安裝OK。

protoc --version 查看是否安裝成功。

➜  ~ protoc --version
libprotoc 2.6.0

先記錄一下手動安裝成功的。有空再按brew在安裝一次。把遇到的坑填了~~



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章