Compile libogg for iOS using Xcode5.1 error

假装没事ソ 提交于 2019-12-08 13:02:14

问题


Environment: Mac OS X 10.9.2, Xcode 5.1. Build shell scripts as below:

#!/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

But terminal logs that:

+ 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

Why "--prefix=../libogg-built/i386: No such file or directory"? It already have been created.

Updated: New and correct shell script as below:

#!/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

回答1:


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

You are likely having an issue with the relative path. It's generally better (if not easier) to use the full path to your install root.

One thing you can try, if this is the issue, is to expand the path and try again ... for e.g.

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

Let us know if that helps! Configure scripts can be very finicky.

Update: Nevermind, it's much more simpler in this case I just realized after hitting submit the first time:

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

... you cannot have an #-to-end-of-line comment when you are continuing a command onto multiple lines. Just remove #--host=x86_64-apple-darwin \ and you should be set.




回答2:


You can refer to https://github.com/firstfan/libspeex-iOS

It compiles OK with latest SDK and latest speex code



来源:https://stackoverflow.com/questions/23089404/compile-libogg-for-ios-using-xcode5-1-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!