Cross-compile Autotools-based Libraries for Official iPhone SDK

后端 未结 2 1808
暖寄归人
暖寄归人 2020-12-24 04:21

Background

I am writing a program that targets several different phones, including the iPhone. The program depends on several thirdparty libraries. I am having dif

2条回答
  •  生来不讨喜
    2020-12-24 04:38

    Ok. This still doesn't build, but it gets much further...

    1. The C preprocessor cannot take an architecture.
    2. The C preprocessor does not accept --sysroot or -isystem (just use '-I').
    3. Use "cpp" instead of "cpp-4.2" (the 4.2 version is defective, and since it is the preprocessor, it doesn't matter which version you use, anyway, so you might as well use the one that works.)

    The updated version of the iphone3.1-configure script is:

    #! /bin/bash
    
    #
    # Program  : iphone3.1-configure
    # Authors  : Michael Aaron Safyan (michaelsafyan@gmail.com)
    # Synopsis :
    #            This program runs the "configure" script generated by the
    #            GNU Autotools in order to cross-compile thirdparty libraries
    #            for the iPhone 3.1 SDK. Run this script while in a directory
    #            containing an autotools "configure" script. Once you run this,
    #            you can use "make" and "sudo make install" to build the library.
    #            An install prefix of "/opt/iphone-3.1/" is used.
    #
    
    unset CPATH
    unset C_INCLUDE_PATH
    unset CPLUS_INCLUDE_PATH
    unset OBJC_INCLUDE_PATH
    unset LIBS
    unset DYLD_FALLBACK_LIBRARY_PATH
    unset DYLD_FALLBACK_FRAMEWORK_PATH
    
    export BUILD_DARWIN_VER=`uname -r`
    export SDKVER="3.1"
    export DEVROOT="/Developer/Platforms/iPhoneOS.platform/Developer"
    export SDKROOT="$DEVROOT/SDKs/iPhoneOS$SDKVER.sdk"
    export PKG_CONFIG_PATH=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$SDKVER.sdk/usr/lib/pkgconfig:/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/pkgconfig:/opt/iphone-$SDKVER/lib/pkgconfig:/usr/local/iphone-$SDKVER/lib/pkgconfig
    export PREFIX="/opt/iphone-$SDKVER"
    export AS="$DEVROOT/usr/bin/as"
    export ASCPP="$DEVROOT/usr/bin/as"
    export AR="$DEVROOT/usr/bin/ar"
    export RANLIB="$DEVROOT/usr/bin/ranlib"
    export CPPFLAGS="-pipe -no-cpp-precomp -I$SDKROOT/usr/lib/gcc/arm-apple-darwin9/4.2.1/include/ -I$SDKROOT/usr/include -I$DEVROOT/usr/include -I/opt/iphone-$SDKVER/include -I/usr/local/iphone-$SDKVER/include"
    export CFLAGS="-std=c99 -arch armv6 -pipe -no-cpp-precomp --sysroot='$SDKROOT' -isystem $SDKROOT/usr/lib/gcc/arm-apple-darwin9/4.2.1/include/ -isystem $SDKROOT/usr/include -isystem $DEVROOT/usr/include -isystem /opt/iphone-$SDKVER/include -isystem /usr/local/iphone-$SDKVER/include"
    export CXXFLAGS="-std=c99 -arch armv6 -pipe -no-cpp-precomp --sysroot='$SDKROOT' -isystem $SDKROOT/usr/lib/gcc/arm-apple-darwin9/4.2.1/include/ -isystem $SDKROOT/usr/include -isystem $DEVROOT/usr/include -isystem /opt/iphone-$SDKVER/include -isystem /usr/local/iphone-$SDKVER/include"
    export LDFLAGS="-arch armv6 --sysroot='$SDKROOT' -L$SDKROOT/usr/lib -L$DEVROOT/usr/lib -L/opt/iphone-$SDKVER/lib -L/usr/local/iphone-$SDKVER/lib"
    export CPP="$DEVROOT/usr/bin/cpp"
    export CXXCPP="$DEVROOT/usr/bin/cpp"
    export CC="$DEVROOT/usr/bin/gcc-4.2"
    export CXX="$DEVROOT/usr/bin/g++-4.2"
    export LD="$DEVROOT/usr/bin/ld"
    export STRIP="$DEVROOT/usr/bin/strip"
    
    if [ ! \( -d "$DEVROOT" \) ] ; then
       echo "The iPhone SDK could not be found. Folder \"$DEVROOT\" does not exist."
       exit 1
    fi
    
    if [ ! \( -d "$SDKROOT" \) ] ; then
       echo "The iPhone SDK could not be found. Folder \"$SDKROOT\" does not exist."
       exit 1
    fi
    
    ./configure --prefix="$PREFIX" --build="i386-apple-darwin$BUILD_DARWIN_VER" --host="arm-apple-darwin9" --enable-static --disable-shared ac_cv_file__dev_zero=no ac_cv_func_setpgrp_void=yes $@
    

    Also, I am invoking with "--enable-threads --disable-dso", not just "--disable-dso". This still doesn't work... it is failing with:

    checking for PTHREAD_PROCESS_SHARED in pthread.h... yes
    checking for pthread_mutexattr_setpshared... yes
    checking for working PROCESS_SHARED locks... configure: error: in `/Users/michaelsafyan/Downloads/apr-1.3.8':
    configure: error: cannot run test program while cross compiling
    See `config.log' for more details.
    

    However, this may be a problem with APR's specific tests. I am posting a followup question at the link.

    Edit

    I have provided a more complete solution at Cross-compiling the Apache Portable Runtime for the iPhone.

提交回复
热议问题