为arm64编译Libical,为iOS编译x86_64 [英] Compiling Libical for arm64 and x86_64 for iOS

查看:414
本文介绍了为arm64编译Libical,为iOS编译x86_64的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了一些时间来为iOS(设备和模拟器)编译用于arm64和x86_64架构的LibiCal。认为它可能对其他人有用。以下是我编译LibiCal-1.0时的步骤。我已从以下链接中获取代码

It took some time for me to compile LibiCal for arm64 and x86_64 architecture for iOS(device and simulator). Thought it may be useful for others. Here is the steps I followed to compile LibiCal-1.0. I have taken code from below link

编译libical

并修改了一下以适应Xcode 5.1

and modified a bit to suit for Xcode 5.1

1)从以下网址下载LibiCal

1) download LibiCal from below URL

http://sourceforge.net/projects/ freeassociation /

Untar并进入libCal-1.0文件夹。然后运行

Untar and get into libCal-1.0 folder. Then run

./ bootstrap

./bootstrap

(需要从 http://www.jattcode.com/installing-autoconf-automake-libtool -on-mac-osx-mountain-lion /

使用以下脚本

#!/bin/sh

# SEE: http://www.smallsharptools.com/downloads/libical/

PATH="`xcode-select -print-path`/usr/bin:/usr/bin:/bin"

# set the prefix
PREFIX=${HOME}/Library/libical
OUTPUTDIR=../libical-build

export ARCH=arm64

# Select the desired iPhone SDK
export SDKVER="7.1"
export DEVROOT=`xcode-select --print-path`
export  SDKROOT=$DEVROOT/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk
export IOSROOT=$DEVROOT/Platforms/iPhoneOS.platform

# Includes
# find $DEVROOT -type d -name include|grep -i iphone|grep -i arm-apple-darwin|grep -vi    install-tools|grep -vi simulator

# $SDKROOT/usr/include
# $DEVROOT/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/lib/gcc/arm-apple-darwin10/4.2.1/include

if [ ! -d $DEVROOT ]
then
        echo "Developer Root not found! - $DEVROOT"
        exit
fi

echo "DEVROOT = $DEVROOT"

if [ ! -d $SDKROOT ]
then
        echo "SDK Root not found! - $SDKROOT"
        exit
fi

echo "SDKROOT = $SDKROOT"

if [ ! -d $IOSROOT ]
then
        echo "iOS Root not found! - $IOSROOT"
        exit
fi

echo "IOSROOT = $IOSROOT"

# finding ld
# find $DEVROOT -type f -name ld|grep -i iphone

# Set up relevant environment variables 
export CPPFLAGS="-arch $ARCH -I$SDKROOT/usr/include -I$IOSROOT/Developer/usr/llvm-gcc-4.2/lib/gcc/arm-apple-darwin10/4.2.1/include"
export CFLAGS="$CPPFLAGS -pipe -no-cpp-precomp -isysroot $SDKROOT"
export CXXFLAGS="$CFLAGS"
export LDFLAGS="-L$SDKROOT/usr/lib/ -arch $ARCH"

export CLANG=$DEVROOT/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang

#export CC=$IOSROOT/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2
#export CXX=$IOSROOT/Developer/usr/bin/arm-apple-darwin10-llvm-g++-4.2

export CC=$CLANG
export CXX=$CLANG
export LD=$IOSROOT/Developer/usr/bin/ld
export AR=$IOSROOT/Developer/usr/bin/ar 
export AS=$IOSROOT/Developer/usr/bin/as 
export LIBTOOL=$IOSROOT/usr/bin/libtool 
export STRIP=$IOSROOT/Developer/usr/bin/strip 
export RANLIB=$IOSROOT/Developer/usr/bin/ranlib

HOST=arm-apple-darwin10

if [ ! -f $CC ]
then
        echo "C Compiler not found! - $CC"
        exit
fi

if [ ! -f $CXX ]
then
        echo "C++ Compiler not found! - $CXX"
        exit
fi

if [ ! -f $LD ]
then
        echo "Linker not found! - $LD"
        exit
fi

if [ -d $OUTPUTDIR/$ARCH ]
then 
       rm -rf $OUTPUTDIR/$ARCH
fi

find . -name \*.a -exec rm {} \;
make clean

./configure --prefix=$PREFIX --disable-dependency-tracking --host $HOST CXX=$CXX CC=$CC LD=$LD AR=$AR AS=$AS LIBTOOL=$LIBTOOL STRIP=$STRIP RANLIB=$RANLIB

make -j4

# copy the files to the arch folder

mkdir -p $OUTPUTDIR
mkdir -p $OUTPUTDIR/$ARCH

cp `find . -name \*.a` $OUTPUTDIR/$ARCH/

xcrun -sdk iphoneos lipo -info $OUTPUTDIR/$ARCH/*.a

echo $ARCH DONE

echo "See $OUTPUTDIR"

修改行:11export ARCH = arm64获得所需的架构,即arm64,armv7,armv7s。

modify the line:11 "export ARCH=arm64" to get desired architecture, i.e. arm64, armv7, armv7s.

这应该在../libical-build文件夹中为所需的架构创建垃圾箱。

This should create bins for desired architecture in ../libical-build folder.

使用以下命令运行x86_64的get build。

Use following commands to run get build for x86_64.

tar -xovf libical-1.0.tar
cd libical-1.0
./bootstrap
./configure
make

这应该在文件夹src / libical / .libs / libical.a中创建libical.a。

This should create libical.a in folder src/libical/.libs/libical.a.

使用以下命令构建胖库。 (请使用适当的脂肪指令)。

Use below command to build the fat library. (Please use appropriate lipo command).

export DEVROT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/lip

$DEVROOT/usr/bin/lipo 
    -arch arm64 $OUTPUTDIR/armv6/libical.a 
    -arch i386 $OUTPUTDIR/i386/libical_Simulator.a 
    -arch armv7 $OUTPUTDIR/x86_64/libical.a 
    -arch armv7s $OUTPUTDIR/x86_64/libical.a 
    -arch x86_64 $OUTPUTDIR/x86_64/libical.a 
    -create -output $OUTPUTDIR/libical_fat_universal.a

请设置适当的OUTPUTDIR环境变量。

Please set appropriate OUTPUTDIR environment variable.

我希望上面会帮助一些想要快速构建iOS的Libical的人。

I hope above will help some one who wants to quickly build Libical for iOS.

推荐答案

我有找到了解决问题的方法。我做的主要是添加以下开关

I have found a fix for the issue. The main thing I did was add the following switch

-mios-simulator-version-min=7.0

这是我目前的剧本版本:

Here is my current version of the script:

 #!/bin/sh

set -o xtrace

# SEE: http://www.smallsharptools.com/downloads/libical/

PATH="`xcode-select -print-path`/usr/bin:/usr/bin:/bin"


if [ ! -n "$ARCH" ]; then
    export ARCH=armv7
fi


# Select the desired iPhone SDK
export SDKVER="7.1"
export DEVROOT=`xcode-select --print-path`

if [ "i386" = $ARCH ] || [ "x86_64" = $ARCH ]; then
    export SDKROOT=$DEVROOT/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVER}.sdk
    export MIOS="-mios-simulator-version-min=7.0"
else
    export SDKROOT=$DEVROOT/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk
    export MIOS=""
fi;
export IOSROOT=$DEVROOT/Platforms/iPhoneOS.platform



if [ ! -d $DEVROOT ]
then
        echo "Developer Root not found! - $DEVROOT"
        exit 1
fi

echo "DEVROOT = $DEVROOT"

if [ ! -d $SDKROOT ]
then
        echo "SDK Root not found! - $SDKROOT"
        exit 1
fi

echo "SDKROOT = $SDKROOT"

if [ ! -d $IOSROOT ]
then
        echo "iOS Root not found! - $IOSROOT"
        exit 1
fi

echo "IOSROOT = $IOSROOT"

# Set up relevant environment variables 
export CPPFLAGS="-arch $ARCH -I$SDKROOT/usr/include $MIOS --debug"
export CFLAGS="$CPPFLAGS -pipe -no-cpp-precomp -isysroot $SDKROOT "
export CXXFLAGS="$CFLAGS"
export LDFLAGS="-L$SDKROOT/usr/lib/ -arch $ARCH"

export CLANG=$DEVROOT/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang


export CC=$CLANG
export CXX=$CLANG
export LD=$IOSROOT/Developer/usr/bin/ld
export AR=$IOSROOT/Developer/usr/bin/ar 
export AS=$IOSROOT/Developer/usr/bin/as 
export LIBTOOL=$IOSROOT/usr/bin/libtool 
export STRIP=$IOSROOT/Developer/usr/bin/strip 
export RANLIB=$IOSROOT/Developer/usr/bin/ranlib
export LIPO="xcrun -sdk iphoneos lipo"
export HOST=arm-apple-darwin10


if [ ! -f $CC ]
then
        echo "C Compiler not found! - $CC"
        exit
fi

if [ ! -f $CXX ]
then
        echo "C++ Compiler not found! - $CXX"
        exit
fi

if [ ! -f $LD ]
then
        echo "Linker not found! - $LD"
        exit
fi

if [ -d $OUTPUT_DIR/$ARCH ]
then 
       rm -rf $OUTPUT_DIR/$ARCH
fi

find ./src -name \*.a -exec rm {} \;
make clean


./configure --prefix="$OUTPUT_DIR" --disable-dependency-tracking --host $HOST CXX=$CXX CC=$CC LD=$LD AR=$AR AS=$AS LIBTOOL=$LIBTOOL STRIP=$STRIP RANLIB=$RANLIB

make -j4

# copy the files to the arch folder

mkdir -p $OUTPUT_DIR
mkdir -p $OUTPUT_DIR/$ARCH

cp `find . -name \*.a` $OUTPUT_DIR/$ARCH/
cp config.log $OUTPUT_DIR/$ARCH/config.log

$LIPO -info $OUTPUT_DIR/$ARCH/*.a

echo $ARCH DONE

echo "See $OUTPUT_DIR"

我已经开始为这个库构建一个Objective C包装器,你可以看到
的进度 https://github.com/ahalls/XbICalendar 我可以使用一些眼球提出建议甚至帮助。

I've started building out a Objective C wrapper for this library and you can see the progress at https://github.com/ahalls/XbICalendar I the project could use some eyeballs with suggestions and even some help.

这篇关于为arm64编译Libical,为iOS编译x86_64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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