如何实现protobuf在XCODE上armv7/armv7s/i386的交叉编译 / 蓝讯
发布网友
发布时间:2022-04-24 22:48
我来回答
共1个回答
热心网友
时间:2023-10-13 23:05
步骤一:部署protoc.exe
1)sudo su ---进入管理模式
//以下操作切换至protobuf文件夹下
2)。/configure
3)make
4)make check
5)make install
此时可以查看protobuf文件夹下面的makefile文件,可以查看-build表示的本机环境以及-host表示的编译库的运行环境
我本地的-build=x86_64-apple-darwin12.3.0
-host=x86_64-apple-darwin12.3.0
(这两个参数在后续配置脚本需要用到,与后面脚步的i686-apple-darwin12.3.0以及arm-apple-darwin12.3.0后缀“arm-apple-darwin12.3.0”保持一致)
6)make distclean清理已生成的makefile,为交叉编译配置新makefile做准备
步骤二:配置交叉编译
1)执行脚本ios-build.sh,脚本内容如下:
configure_for_platform() {
export PLATFORM=$1
#export PLATFORM=iPhoneOS
echo “Platform is ${PLATFORM}”
if [ “$PLATFORM” == “iPhoneSimulator” ]; then
export ARCHITECTURE=i386
export ARCH=i686-apple-darwin12.3.0
fi
if [ “$PLATFORM” == “iPhoneOS” ]; then
export ARCHITECTURE=$2
export ARCH=arm-apple-darwin12.3.0
fi
export ARCH_PREFIX=$ARCH-
export SDKVER=“6.1”
#sdk版本号必须正确
export
DEVROOT=/Applications/Xcode.app/Contents/Developer/Platforms/${PLATFORM}.platform/Developer
export SDKROOT=“$DEVROOT/SDKs/${PLATFORM}$SDKVER.sdk”
export
PKG_CONFIG_PATH=“$SDKROOT/usr/lib/pkgconfig:$DEVROOT/usr/lib/pkgconfig”
export AS=“$DEVROOT/usr/bin/as”
export ASCPP=“$DEVROOT/usr/bin/as”
export AR=“$DEVROOT/usr/bin/ar”
export RANLIB=“$DEVROOT/usr/bin/ranlib”
#export CPP=“$DEVROOT/usr/bin/c++”
#export CXXCPP=“$DEVROOT/usr/bin/c++”
export CC=“$DEVROOT/usr/bin/gcc”
export CXX=“$DEVROOT/usr/bin/g++”
export LD=“$DEVROOT/usr/bin/ld”
export STRIP=“$DEVROOT/usr/bin/strip”
export LIBRARY_PATH=“$SDKROOT/usr/lib”
export CPPFLAGS=“”