0

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
Smeegol
  • 2,014
  • 4
  • 29
  • 44

2 Answers2

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.

greymouser
  • 3,133
  • 19
  • 22
  • Yeah you are right! I have change the prefix to the full path and delete the comment. It works now! Thank you so much. – Smeegol Apr 16 '14 at 03:29
  • I already update my shell script. It runs correctly, but still some warings: "configure: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used configure: WARNING: using cross tools not prefixed with host triplet", do you know why? the "--host=arm-apple-darwin \" should be deleted? – Smeegol Apr 16 '14 at 03:37
  • Look for `--arch`, `--host`, or even `--cross-compile` type options in the configure script. (It looks like you are setting the arch in the CC and CXX vars). Each configure script can be different. One or more of those options are likely needed to allow the host (your Mac) cross compile for iOS (armv7,avrmv7s,arm64). I have an FFmpeg iOS build script available here - https://github.com/greymouser/ffmpeg-build-ios/blob/master/build-ffmpeg.sh - it may give you some insight. However, the libogg configure script is bound to be different than FFmpeg's -- so just use it as reference. – greymouser Apr 16 '14 at 13:38
  • Can you have a look at my another question that is relative to this one? http://stackoverflow.com/questions/23104759/compile-libspeex-for-ios-using-xcode5-1-error – Smeegol Apr 16 '14 at 18:52
1

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

It compiles OK with latest SDK and latest speex code

Evan JIANG
  • 690
  • 6
  • 5
  • It should be a comment. – Opal Apr 18 '15 at 08:19
  • @Evan your build scripts were super helpful! I was running into a very weird issue in which my pcre library, which had slices for i386, x86_64, armv6, armv7, and arm64 suddenly refused to work for simulators after upgrading to XCode 7 beta. Although it could see the x86_64 and i386 slices, it said they were built for OSX rather than iOS. Your build script apparently built them "correctly" and it started working again. Really saved me! – Danny Aug 25 '15 at 04:51