1

See also: Compile libogg for iOS using Xcode5.1 error

Environment: Mac OS X 10.9.2, Xcode 5.1.

There are two shell scripts to build libogg and libspeex, where locates in the same directory. The libogg build scripts is as below:

#!/bin/sh

set -xe

VERSION="1.3.1"
BUILDDIR=`pwd`
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

    make distclean

    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=$BUILDDIR/$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=$BUILDDIR/$DESTDIR/$ARCH
        ;;
    esac

    make
    make install
done

make distclean

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

Run scripts in the terminal, and libogg was successfully compiled. Then Run the libspeex scripts as below:

#!/bin/sh

set -xe

VERSION="1.2rc1"
BUILDDIR=`pwd`
OGGDIR="libogg-built"
DESTDIR="libspeex-built"
LIBS="libspeex.a libspeexdsp.a"
ARCHS="i386 x86_64 armv7 armv7s arm64"

rm -rf $DESTDIR
mkdir $DESTDIR

if [ ! -e "speex-$VERSION.tar.gz" ]; then
    curl -LO http://downloads.xiph.org/releases/speex/speex-$VERSION.tar.gz
fi

tar zxf speex-$VERSION.tar.gz
cd speex-$VERSION


./configure

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

    make distclean

    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=$BUILDDIR/$DESTDIR/$ARCH \
        --with-ogg=$BUILDDIR/$OGGDIR/$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=$BUILDDIR/$DESTDIR/$ARCH \
        --with-ogg=$BUILDDIR/$OGGDIR/$ARCH
        ;;
    esac

    make
    make install
done

make distclean

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

for LIB in $LIBS;
do
    INPUT=""
    for ARCH in $ARCHS;
    do
        INPUT="$INPUT $DESTDIR/$ARCH/lib/$LIB"
    done
    lipo -create $INPUT -output $DESTDIR/universal/lib/$LIB
done

It says that ./build-libspeex.sh: line 55: --with-ogg=/Users/Smeegol/Desktop/Speex/libogg-built/i386: No such file or directory, why i386 cannot be located, it has been created at the previous step?!

Community
  • 1
  • 1
Smeegol
  • 2,014
  • 4
  • 29
  • 44

2 Answers2

1

It says that ./build-libspeex.sh: line 55: --with-ogg=/Users/Smeegol/Desktop/Speex/libogg-built/i386: No such file or directory, why i386 cannot be located, it has been created at the previous step?!

It references /Users/Smeegol/Desktop/Speex/libogg-built/i386, and yet in the previous step ...

lipo -create $INPUT -output $DESTDIR/universal/lib/libogg.a

... I see universal in the path name, for one.

Your output directory for the libogg install should look something like this:

${OGGDIR}/lib/libogg.a
${OGGDIR}/include/<include files here>

And finally, you have a similar error to your other question:

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=$BUILDDIR/$DESTDIR/$ARCH
    --with-ogg=$BUILDDIR/$OGGDIR/$ARCH

... you are missing a "\" after the --prefix line.

greymouser
  • 3,133
  • 19
  • 22
-1

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

It compiles OK with latest SDK and latest speex code

It works out-of-box.

Evan JIANG
  • 690
  • 6
  • 5
  • Welcome. While the link may provide the answer, it is required to include the answer (or at list the mainlines) into the post in addition of the link. This ensures the post remains useful if the linked resource is moved or deleted. – mins Apr 18 '15 at 08:24