protobuf 静态编译

一.protobuf 安装
protobuf版本:2.6.1

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

解压之后进入目录

修改autogen.sh

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

修改后

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.sh

./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
完成。

二:在其他平台
安卓平台脚本
protobuf_android_armeabi-v7a_static.sh

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.sh

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.sh

./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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值