使用Xcode5.1错误编译iOS的libogg

时间:2014-04-15 16:26:31

标签: ios xcode macos ogg speex

环境:Mac OS X 10.9.2,Xcode 5.1。构建shell脚本如下:

#!/bin/sh

set -xe

VERSION="1.3.1"
DESTDIR="libogg-built"

#ARCHS="i386 x86_64 armv7 armv7s arm64"

rm -rf $DESTDIR
mkdir $DESTDIR

if [ ! -e "libogg-$VERSION.zip" ]; then
    curl -LO http://downloads.xiph.org/releases/ogg/libogg-$VERSION.zip
fi

unzip -oq libogg-$VERSION.zip
cd libogg-$VERSION


./configure

for ARCH in $ARCHS;
do
    mkdir -p ../$DESTDIR/$ARCH

    IOSMV="-miphoneos-version-min=4.3"
    case $ARCH in
    arm*)
        if [ $ARCH == "arm64" ]; then
            IOSMV="-miphoneos-version-min=7.0"
        fi
        PATH=`xcodebuild -version -sdk iphoneos PlatformPath`"/Developer/usr/bin:$PATH" \
        SDK=`xcodebuild -version -sdk iphoneos Path` \
        CC="xcrun --sdk iphoneos clang -arch $ARCH $IOSMV --sysroot=$SDK -isystem $SDK/usr/include" \
        CXX="xcrun --sdk iphoneos clang++ -arch $ARCH $IOSMV --sysroot=$SDK -isystem $SDK/usr/include" \
        LDFLAGS="-Wl,-syslibroot,$SDK" \
        ./configure \
        #--host=arm-apple-darwin \
        --prefix=../$DESTDIR/$ARCH
        ;;
    *)
        PATH=`xcodebuild -version -sdk iphonesimulator PlatformPath`"/Developer/usr/bin:$PATH" \
        #SDK=`xcodebuild -version -sdk iphonesimulator Path` \
        CC="xcrun --sdk iphonesimulator clang -arch $ARCH $IOSMV" \
        CXX="xcrun --sdk iphonesimulator clang++ -arch $ARCH $IOSMV" \
        ./configure \
        #--host=x86_64-apple-darwin \
        --prefix=../$DESTDIR/$ARCH
        ;;
    esac

    make
    make install
    make clean
done

cd ..
mkdir -p ${DESTDIR}/universal/lib

INPUT=""
for ARCH in $ARCHS; 
do
    INPUT="$INPUT $DESTDIR/$ARCH/lib/libogg.a"
done
lipo -create $INPUT -output $DESTDIR/universal/lib/libogg.a

但终端记录:

+ VERSION=1.3.1
+ DESTDIR=libogg-built
+ ARCHS=i386
+ rm -rf libogg-built
+ mkdir libogg-built
+ '[' '!' -e libogg-1.3.1.zip ']'
+ unzip -oq libogg-1.3.1.zip
+ cd libogg-1.3.1
+ ./configure
+ for ARCH in '$ARCHS'
+ mkdir -p ../libogg-built/i386
+ IOSMV=-miphoneos-version-min=4.3
+ case $ARCH in
++ xcodebuild -version -sdk iphonesimulator PlatformPath
+ PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/opt/local/bin:/opt/local/sbin:/Users/Smeegol/.rbenv/shims:/Users/Smeegol/.rbenv/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
+ CC='xcrun --sdk iphonesimulator clang -arch i386 -miphoneos-version-min=4.3'
+ CXX='xcrun --sdk iphonesimulator clang++ -arch i386 -miphoneos-version-min=4.3'
+ ./configure
+ --prefix=../libogg-built/i386
./build-libogg2.sh: line 55: --prefix=../libogg-built/i386: No such file or directory

为什么“--prefix=../libogg-built/i386: No such file or directory”?它已经创建了。

已更新:新的正确的shell脚本如下所示:

#!/bin/sh

set -xe

VERSION="1.3.1"
DESTDIR="libogg-built"

ARCHS="i386 x86_64 armv7 armv7s arm64"

rm -rf $DESTDIR
mkdir $DESTDIR

if [ ! -e "libogg-$VERSION.zip" ]; then
    curl -LO http://downloads.xiph.org/releases/ogg/libogg-$VERSION.zip
fi

unzip -oq libogg-$VERSION.zip
cd libogg-$VERSION


./configure

for ARCH in $ARCHS;
do
    mkdir -p ../$DESTDIR/$ARCH

    IOSMV="-miphoneos-version-min=4.3"
    case $ARCH in
    arm*)
        if [ $ARCH == "arm64" ]; then
            IOSMV="-miphoneos-version-min=7.0"
        fi
        PATH=`xcodebuild -version -sdk iphoneos PlatformPath`"/Developer/usr/bin:$PATH" \
        SDK=`xcodebuild -version -sdk iphoneos Path` \
        CC="xcrun --sdk iphoneos clang -arch $ARCH $IOSMV --sysroot=$SDK -isystem $SDK/usr/include" \
        CXX="xcrun --sdk iphoneos clang++ -arch $ARCH $IOSMV --sysroot=$SDK -isystem $SDK/usr/include" \
        LDFLAGS="-Wl,-syslibroot,$SDK" \
        ./configure \
        --host=arm-apple-darwin \
        --prefix=../$DESTDIR/$ARCH
        ;;
    *)
        PATH=`xcodebuild -version -sdk iphonesimulator PlatformPath`"/Developer/usr/bin:$PATH" \
        CC="xcrun --sdk iphonesimulator clang -arch $ARCH $IOSMV" \
        CXX="xcrun --sdk iphonesimulator clang++ -arch $ARCH $IOSMV" \
        ./configure \
        --prefix=../$DESTDIR/$ARCH
        ;;
    esac

    make
    make install
    make clean
done

cd ..
mkdir -p $DESTDIR/universal/lib

INPUT=""
for ARCH in $ARCHS; 
do
    INPUT="$INPUT $DESTDIR/$ARCH/lib/libogg.a"
done
lipo -create $INPUT -output $DESTDIR/universal/lib/libogg.a

2 个答案:

答案 0 :(得分:1)

--prefix=../$DESTDIR/$ARCH

您可能遇到相对路径问题。使用安装根目录的完整路径通常会更好(如果不是更容易)。

如果这是问题,您可以尝试的一件事是扩展路径并再试一次......例如。

export INSTALL_ROOT=$(cd ../libogg-built/i386; pwd)
./configure ...
...
--prefix="${INSTALL_ROOT}"

如果有帮助,请告诉我们!配置脚本可能非常挑剔。

更新:没关系,在这种情况下,我在第一次点击提交后才意识到这一点要简单得多:

    CXX="xcrun --sdk iphonesimulator clang++ -arch $ARCH $IOSMV" \
    ./configure \
    #--host=x86_64-apple-darwin \
    --prefix=../$DESTDIR/$ARCH
    ;;

...当你将命令连续到多行时,你不能有#-to-end-of-line注释。只需删除#--host=x86_64-apple-darwin \即可设置。

答案 1 :(得分:1)

你可以参考 https://github.com/firstfan/libspeex-iOS

使用最新的SDK和最新的speex代码编译好