如何为iOS7构建协议缓冲区? [英] how to build protocol buffer for iOS7?

查看:100
本文介绍了如何为iOS7构建协议缓冲区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在xcode5中重建协议缓冲区staticlib,

b $ b下载协议缓冲区 http://code.google.com/p/protobuf/downloads/list
使用autogen.sh,我得到一个配置文件,可以在mac上制作和安装,我写了一个shell脚本尝试为iOS构建glib,如下:

I want to rebuild protocol buffer staticlib in xcode5 ,
download protocol buffer in http://code.google.com/p/protobuf/downloads/list use autogen.sh , I get a configure file, can make and install on mac, I write a shell script try to build glib for iOS, as blow :

export ARCH=arm-apple-darwin10
export ARCH_PREFIX=${ARCH}-
export PLATFORM=iPhoneOS

export SDKVER=7.0
export DEVROOT=/Applications/Xcode.app/Contents/Developer/Platforms/${PLATFORM}.platform/Developer
export SDKROOT="$DEVROOT/SDKs/${PLATFORM}$SDKVER.sdk"

export Toolchains=/Applications/Xcode.app/Contents/Developer/Toolchains
export XcodeClangBin="$Toolchains/XcodeDefault.xctoolchain/usr/bin"
export XcodeCpp="$Toolchains/XcodeDefault.xctoolchain/usr/bin/cpp"

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="$XcodeCpp"
export CXXCPP="$XcodeCpp"
export CC="$XcodeClangBin/clang"
export CXX="$XcodeClangBin/clang++"
export LD="$DEVROOT/usr/bin/ld"
export STRIP="$DEVROOT/usr/bin/strip"

export CPPFLAGS="-pipe -no-cpp-precomp -I$SDKROOT/usr/include"
export CFLAGS="-arch armv7 -arch armv7s -fmessage-length=0 -pipe -fpascal-strings -no-cpp-precomp -miphoneos-version-min=5.0 --sysroot='$SDKROOT' -isystem $SDKROOT/usr/include"
export CXXFLAGS="$CFLAGS -I$SDKROOT/usr/include/c++/4.2.1/${ARCH}/v6"
export LDFLAGS="--sysroot='$SDKROOT' -L$SDKROOT/usr/lib -L$SDKROOT/usr/lib/system"

./configure --host=${ARCH} --with-protoc=protoc --enable-static --disable-shared --prefix=/tmp/protobuf/arm
make clean
make
make check
make install

当我运行此脚本时,返回为:

When I run this script, return as :

#error Unsupported architecture

我该怎么办?

在ios6,xcode 4.6中,我可以使用此配置文件进行构建,但在xcode5中,llvm-gcc已删除,我使用clang替换它,但是失败了。

in ios6, xcode 4.6, i can use this configure file to build, but in xcode5, llvm-gcc has removed, i use clang to replace it, but is failed.

在ios6中,使用此

export CPP="$DEVROOT/usr/bin/llvm-cpp-4.2"
export CXXCPP="$DEVROOT/usr/bin/llvm-cpp-4.2"


推荐答案

我写了一个小的bash脚本,为iOS 7构建Protobuf。可以在这里找到脚本。

I wrote a small bash script that builds Protobuf for iOS 7. The script can be found here.

https://gist.github.com/BennettSmith/7150245

此脚本将生成适当的Google Protobuf版本,支持i386,armv7,armv7s,arm64和x86_64架构。它将生成一个通用的静态库。它还将生成用于OS X的protoc编译器。

This script will produce a proper build of Google Protobuf that supports the i386, armv7, armv7s, arm64 and x86_64 architectures. It will produce a static library that is universal. It will also produce the protoc compiler for use on OS X.

这篇关于如何为iOS7构建协议缓冲区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆