1.下载protobuf
下载地址:https://codeload.github.com/google/protobuf/zip/v3.0.0
在文件中解压,并cd到protobuf-3.0.0目录下
2.若有./configure文件,直接执行如下指令
./configure CFLAGS="-fPIC" CXXFLAGS="-fPIC"
make
sudo make install
3.若没有./configure文件,则执行
./autogen.sh
但是会超时,下载失败,我挂了梯子还是失败,查看了该sh文件里面的代码,是到一个外网下载gmock-1.7.0.zip文件。
既然下载失败,就github下载了
git clone https://github.com/paulsapps/gmock-1.7.0
将clone下来的文件夹改名为gmock,即
mv gmock-1.7.0 gmock #手动修改文件夹名的跳过此步骤
然后讲此文件夹复制到./autogen.sh同级目录下,并修改./autogen.sh文件
# 注释掉此部分,此部分内容就是下载文件->解压->修改文件夹名的步骤,上面已经做过了# Check that gmock is present. Usually it is already there since the
# directory is set up as an SVN external.
#if test ! -e gmock; then
# echo "Google Mock not present. Fetching gmock-1.7.0 from the web..."
# curl $curlopts -O https://googlemock.googlecode.com/files/gmock-1.7.0.zip
# unzip -q gmock-1.7.0.zip
# rm gmock-1.7.0.zip
# mv gmock-1.7.0 gmock
#fi
然后就可以按第2部分进行编译了
./autogen.sh
./configure CFLAGS="-fPIC" CXXFLAGS="-fPIC"
make
sudo make install