protobuf 静态编译

一.protobuf 安装
protobuf版本:2.6.1linux

下载地址:https://github.com/google/protobuf/archive/v2.6.1.zipandroid

解压以后进入目录git

修改autogen.shgithub

echo "Google Test not present.  Fetching gtest-1.5.0 from the web..."
curl http://googletest.googlecode.com/files/gtest-1.5.0.tar.bz2 | tar jx
mv gtest-1.5.0 gtest

修改后web

wget https://github.com/google/googletest/archive/release-1.5.0.tar.gz
tar xzvf release-1.5.0.tar.gz
mv googletest-release-1.5.0 gtest

新版源码下载:https://github.com/protocolbuffers/protobuf/releases
能够不修改上面部分,直接执行脚本
进入源码文件夹
写一个脚本
protobuf_static.shubuntu

./autogen.sh
./configure --prefix=/home/zl/Workspace/git/protobuf_my/build --enable-shared=no CFLAGS="-fPIC -fvisibility=hidden" CXXFLAGS="-fPIC -fvisibility=hidden" || exit 1
make clean
make -j6 || exit 1
make install

在终端执行
sh protobuf_static.sh
完成。curl

二:在其余平台
安卓平台脚本
protobuf_android_armeabi-v7a_static.shide

export PATH=/home/facex/arm-linux-androideabi/bin:$PATH
# Tell configure what tools to use.
target_host=arm-linux-androideabi
export AR=$target_host-ar
export AS=$target_host-clang
export CC=$target_host-clang
export CXX=$target_host-clang++
export LD=$target_host-ld
export STRIP=$target_host-strip

./autogen.sh
./configure --prefix=/home/facex/arm-linux-androideabi/sysroot/usr --with-protoc=protoc --host=arm-linux-androideabi --enable-shared=no CFLAGS="-fPIC -fvisibility=hidden" CXXFLAGS="-mfpu=neon -fPIC -fvisibility=hidden" LDFLAGS="-llog -lz" || exit 1
make clean
make -j6 || exit 1
make install

protobuf_android_arm64-v8a_static.shsvg

export PATH=/home/facex/aarch64-linux-android/bin:$PATH
# Tell configure what tools to use.
target_host=aarch64-linux-android
export AR=$target_host-ar
export AS=$target_host-clang
export CC=$target_host-clang
export CXX=$target_host-clang++
export LD=$target_host-ld
export STRIP=$target_host-strip

./autogen.sh
./configure --prefix=/home/facex/aarch64-linux-android/sysroot/usr --with-protoc=protoc --host=aarch64-linux-android --enable-shared=no CFLAGS="-fPIC -fvisibility=hidden" CXXFLAGS="-fPIC -fvisibility=hidden" LDFLAGS="-llog -lz" || exit 1
make clean
make -j6 || exit 1
make install

三:arm-linux 平台编译
protobuf_armhf_static.shui

./autogen.sh
./configure --prefix=/home/facex/ubuntu-armhf/usr/local --with-protoc=protoc --host=arm-linux-gnueabihf --enable-shared=no CFLAGS="-fPIC -fvisibility=hidden -mfpu=neon" CXXFLAGS="-fPIC -fvisibility=hidden -mfpu=neon" || exit 1
make clean
make -j6 || exit 1
make install

protobuf_aarch64_static.sh

./autogen.sh
./configure --prefix=/home/facex/ubuntu-aarch64/usr/local --with-protoc=protoc --host=aarch64-linux-gnu --enable-shared=no CFLAGS="-fPIC -fvisibility=hidden" CXXFLAGS="-fPIC -fvisibility=hidden" || exit 1
make clean
make -j6 || exit 1
make install