8 Replies Latest reply: Jun 5, 2008 4:09 AM by Clea Rees
chassett Level 1 Level 1 (0 points)
Hello, I am trying to build a library for the iPhone (libcurl to be exact).

When I run ./configure, I supply the --host=arm-apple-darwin parameter, but it still compiles with the i686 compiler. Here is the exact configure command I'm using:

./configure –prefix=/usr/local/iphone –host=arm-apple-darwin –disable-shared –disable-crypto-auth –without-gnutls –without-ssl –without-zlib –without-libssh2 –disable-ipv6 –disable-manual –disable-telnet –disable-tftp –disable-ldap –disable-file –disable-ftp

I notice that when ./configure runs, I see the following in its output, which seems to indicate that it could not find "apple-apple-darwin" toolchain.

What is the best way to set up so that I can do a typical open-source "download-configure-make" cycle and end up with a library that is of a valid (arm) architecture for the iPhone?

--- snip! output from ./configure ---

checking for arm-apple-darwin-ar... no
checking for ar... ar
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking for arm-apple-darwin-strip... no
checking for strip... strip
checking curl version... 7.18.0
checking build system type... i386-apple-darwin9.3.0
checking host system type... arm-apple-darwin
checking for style of include used by make... GNU
checking for arm-apple-darwin-gcc... no
checking for gcc... gcc
  • Jim Dovey Level 1 Level 1 (0 points)
    You will need to set the system root to (by default) "/Developer/Platforms/iPhoneOS.platform/Developer/" when running configure. I'm not sure of the flag to do that, but './configure --help' would probably reveal it.

    The ARM libraries and headers are only installed within the iPhoneOS platform inside the regular Developer directory (or wherever you chose to install the Xcode toolset). As such, everything is inside /usr/* within the Developer directory inside that platform.

    Also, the host platform qualifier appears to be 'arm-apple-darwin9' -- I'm not sure if the '9' is required or not, but I figured it would be worth mentioning, just in case.
  • chassett Level 1 Level 1 (0 points)
    I have experimented with various options -- the configure script does not appear to have a switch to specify the system root (output of ./configure --help is included at the end of this message).

    I have also tried, in various combinations:

    (1) putting /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ at the start of $PATH before running ./configure

    (2) setting the CC environment variable to /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc- 4.0.1 before running ./configure, and also setting CCFLAGS, CFLAGS, and LDFLAGS appropriately

    (3) using arm-apple-darwin9 as the --host parameter to ./configure

    Only method (2) seems to get me any closer -- when I set those variables, ./configure gets further, before finally complaining: "configure: error: couldn't find libraries for gethostbyname()"

    --- snip! my environment variables

    export ApplePubSub_SocketRender="/tmp/launch-9jKbtq/Render"
    export CC="//Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9 -gcc-4.0.1"
    export CFLAGS="-I/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp:/Develop er/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/include/gcc/da rwin/4.0"
    export COMMAND_MODE="unix2003"
    export CPP="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp"
    export CPPFLAGS="-I/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp:/Devel oper/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/include/gcc/ darwin/4.0"
    export DISPLAY="/tmp/launch-Qttop0/:0"
    export HOME="/var/root"
    export LANG="en_US.UTF-8"
    export LDFALSE="-L/Developer/Platforms/iPhoneOS.platform/Developer/lib"
    export LDFLAGS="-L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sd k/usr/lib"
    export LOGNAME="ghassett"
    export MANPATH="/usr/share/man:/usr/local/share/man:/usr/X11/man"
    export OLDPWD="/Developer/Platforms/iPhoneOS.platform"
    export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
    export PWD="/Users/ghassett/Downloads/curl-7.18.0"
    export SECURITYSESSIONID="b0f0a0"
    export SHELL="/bin/sh"
    export SHLVL="2"
    export SSHAUTHSOCK="/tmp/launch-a6PgY1/Listeners"
    export TERM="xterm-color"
    export TERMPROGRAM="AppleTerminal"
    export TERMPROGRAMVERSION="240"
    export TMPDIR="/var/folders/kB/kB6BA7McHZCWMyQM4l1WSU+TI/-Tmp-/"
    export USER="ghassett"
    export _CF_USER_TEXTENCODING="0x1F5:0:0"


    --- snip! the output of ./configure --help, which does not seem to have a flag to point to the gcc tools to use

    `configure' configures curl - to adapt to many kinds of systems.

    Usage: ./configure [OPTION]... [VAR=VALUE]...

    To assign environment variables (e.g., CC, CFLAGS...), specify them as
    VAR=VALUE. See below for descriptions of some of the useful variables.

    Defaults for the options are specified in brackets.

    Configuration:
    -h, --help display this help and exit
    --help=short display options specific to this package
    --help=recursive display the short help of all the included packages
    -V, --version display version information and exit
    -q, --quiet, --silent do not print `checking...' messages
    --cache-file=FILE cache test results in FILE [disabled]
    -C, --config-cache alias for `--cache-file=config.cache'
    -n, --no-create do not create output files
    --srcdir=DIR find the sources in DIR [configure dir or `..']

    Installation directories:
    --prefix=PREFIX install architecture-independent files in PREFIX
    [/usr/local]
    --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
    [PREFIX]

    By default, `make install' will install all the files in
    `/usr/local/bin', `/usr/local/lib' etc. You can specify
    an installation prefix other than `/usr/local' using `--prefix',
    for instance `--prefix=$HOME'.

    For better control, use the options below.

    Fine tuning of the installation directories:
    --bindir=DIR user executables [EPREFIX/bin]
    --sbindir=DIR system admin executables [EPREFIX/sbin]
    --libexecdir=DIR program executables [EPREFIX/libexec]
    --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
    --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
    --localstatedir=DIR modifiable single-machine data [PREFIX/var]
    --libdir=DIR object code libraries [EPREFIX/lib]
    --includedir=DIR C header files [PREFIX/include]
    --oldincludedir=DIR C header files for non-gcc [/usr/include]
    --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
    --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
    --infodir=DIR info documentation [DATAROOTDIR/info]
    --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
    --mandir=DIR man documentation [DATAROOTDIR/man]
    --docdir=DIR documentation root [DATAROOTDIR/doc/curl]
    --htmldir=DIR html documentation [DOCDIR]
    --dvidir=DIR dvi documentation [DOCDIR]
    --pdfdir=DIR pdf documentation [DOCDIR]
    --psdir=DIR ps documentation [DOCDIR]

    Program names:
    --program-prefix=PREFIX prepend PREFIX to installed program names
    --program-suffix=SUFFIX append SUFFIX to installed program names
    --program-transform-name=PROGRAM run sed PROGRAM on installed program names

    System types:
    --build=BUILD configure for building on BUILD [guessed]
    --host=HOST cross-compile to build programs to run on HOST [BUILD]

    Optional Features:
    --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
    --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
    --enable-maintainer-mode enable make rules and dependencies not useful
    (and sometimes confusing) to the casual installer
    --disable-dependency-tracking speeds up one-time build
    --enable-dependency-tracking do not reject slow dependency extractors
    --disable-largefile omit support for large files
    --enable-shared[=PKGS] build shared libraries [default=yes]
    --enable-static[=PKGS] build static libraries [default=yes]
    --enable-fast-install[=PKGS]
    optimize for fast installation [default=yes]
    --disable-libtool-lock avoid locking (might break parallel builds)
    --enable-http Enable HTTP support
    --disable-http Disable HTTP support
    --enable-ftp Enable FTP support
    --disable-ftp Disable FTP support
    --enable-file Enable FILE support
    --disable-file Disable FILE support
    --enable-ldap Enable LDAP support
    --disable-ldap Disable LDAP support
    --enable-ldaps Enable LDAPS support
    --disable-ldaps Disable LDAPS support
    --enable-dict Enable DICT support
    --disable-dict Disable DICT support
    --enable-telnet Enable TELNET support
    --disable-telnet Disable TELNET support
    --enable-tftp Enable TFTP support
    --disable-tftp Disable TFTP support
    --enable-manual Enable built-in manual
    --disable-manual Disable built-in manual
    --enable-libgcc use libgcc when linking
    --enable-ipv6 Enable ipv6 (with ipv4) support
    --disable-ipv6 Disable ipv6 support
    --enable-nonblocking Enable detecting how to do it
    --disable-nonblocking Disable non-blocking socket detection
    --disable-thread don't look for thread-safe functions
    --enable-thread look for thread-safe functions
    --enable-ares=PATH Enable c-ares for name lookups
    --disable-ares Disable c-ares for name lookups
    --enable-verbose Enable verbose strings
    --disable-verbose Disable verbose strings
    --enable-sspi Enable SSPI
    --disable-sspi Disable SSPI
    --enable-debug Enable pedantic debug options
    --disable-debug Disable debug options
    --enable-crypto-auth Enable cryptographic authentication
    --disable-crypto-auth Disable cryptographic authentication
    --enable-cookies Enable cookies support
    --disable-cookies Disable cookies support
    --enable-hidden-symbols Hide internal symbols in library
    --disable-hidden-symbols
    Leave all symbols with default visibility in library

    Optional Packages:
    --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
    --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
    --with-gnu-ld assume the C compiler uses GNU ld [default=no]
    --with-pic try to use only PIC/non-PIC objects [default=use
    both]
    --with-tags[=TAGS] include additional configurations [automatic]
    --with-ldap-lib=libname Specify name of ldap lib file
    --with-lber-lib=libname Specify name of lber lib file
    --with-krb4-includes=DIR
    Specify location of kerberos4 headers
    --with-krb4-libs=DIR Specify location of kerberos4 libs
    --with-krb4=DIR where to look for Kerberos4
    --with-spnego=DIR Specify location of SPNEGO library fbopenssl
    --with-gssapi-includes=DIR
    Specify location of GSSAPI header
    --with-gssapi-libs=DIR Specify location of GSSAPI libs
    --with-gssapi=DIR Where to look for GSSAPI
    --with-ssl=PATH Where to look for OpenSSL, PATH points to the SSL
    installation (default: /usr/local/ssl); when
    possible, set the PKGCONFIGPATH environment
    variable instead of using this option
    --without-ssl disable OpenSSL
    --with-zlib=PATH search for zlib in PATH
    --without-zlib disable use of zlib
    --with-libssh2=PATH Where to look for libssh2, PATH points to the
    LIBSSH2 installation (default: /usr/local/lib); when
    possible, set the PKGCONFIGPATH environment
    variable instead of using this option
    --without-libssh2 disable LIBSSH2
    --with-egd-socket=FILE Entropy Gathering Daemon socket pathname
    --with-random=FILE read randomness from FILE (default=/dev/urandom)
    --with-gnutls=PATH where to look for GnuTLS, PATH points to the
    installation root (default: /usr/local/)
    --without-gnutls disable GnuTLS detection
    --with-nss=PATH where to look for NSS, PATH points to the
    installation root (default: /usr/local/)
    --without-nss disable NSS detection
    --with-ca-bundle=FILE File name to install the CA bundle as
    --without-ca-bundle Don't install the CA bundle
    --with-libidn=PATH Enable libidn usage
    --without-libidn Disable libidn usage

    Some influential environment variables:
    CC C compiler command
    CFLAGS C compiler flags
    LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
    nonstandard directory <lib dir>
    LIBS libraries to pass to the linker, e.g. -l<library>
    CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
    you have headers in a nonstandard directory <include dir>
    CPP C preprocessor

    Use these variables to override the choices made by `configure' or to help
    it to find libraries and programs with nonstandard names/locations.

    Report bugs to http://curl.haxx.se/mail/>.
  • Clea Rees Level 4 Level 4 (1,245 points)
    I think you need to pass the system root setting to the compiler using one of the flags variables. Maybe CFLAGS. I'd check the man page for cc for the relevant options.

    - cfr
  • chassett Level 1 Level 1 (0 points)
    Hi and thank you -- I tried that already (details are in my previous post, along with a full list of my environment variables).

    When running ./configure, you don't pass CFLAGS directly (there is no --CFLAGS=whatever) option. Instead, you set CFLAGS (and CPPFLAGS and LDFLAGS) as environment variables before running ./configure -- I did all this, but still no joy. The next post in this forum (not this thread) describes my current roadblock, having to do with include paths . . .

    Thanks again for taking a look and passing on your advice -- your time and effort is appreciated by (at least) one very frustrated iPhone developer!
  • Clea Rees Level 4 Level 4 (1,245 points)
    chassett wrote:
    Hi and thank you -- I tried that already (details are in my previous post, along with a full list of my environment variables).

    When running ./configure, you don't pass CFLAGS directly (there is no --CFLAGS=whatever) option. Instead, you set CFLAGS (and CPPFLAGS and LDFLAGS) as environment variables before running ./configure -- I did all this, but still no joy. The next post in this forum (not this thread) describes my current roadblock, having to do with include paths . . .

    Don't put "--" in front of it - just "./configure CFLAGS="...""

    - cfr
  • Clea Rees Level 4 Level 4 (1,245 points)
    I think you want something like this:

    ./configure CFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/" LDFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/ -Wl,-syslibroot,/Developer/Platforms/iPhoneOS.platform/Developer/" ...

    though I'm not positive not having used this myself.

    - cfr
  • chassett Level 1 Level 1 (0 points)
    Thanks to everyone for their help. By applying everyone's suggestions, I was able to arrive at a pass at .configure that actually worked. There may be extra switches in the C Flags that aren't necessary, but it at least produces a version of libcurl.a that I can link against in XCode.

    Here is the .configure command, in case anyone else wants to build libcurl for the iPhone:

    ./configure --prefix=/usr/local/iphone --host=arm-apple-darwin --disable-shared --disable-crypto-auth --without-gnutls --without-ssl --without-zlib --without-libssh2 --disable-ipv6 --disable-manual --disable-telnet --disable-tftp --disable-ldap --disable-file --disable-ftp CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-g cc-4.0.1 CFLAGS="-arch armv6 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=2.0 -gdwarf-2 -mthumb -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/inc lude/libxml2 -I/Library/iPhone/include -I/Users/ghassett/HelloWorld/build/HelloWorld.build/Debug-iphoneos/HelloWorld.b uild/DerivedSources -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk" CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar

    Note that you also have to modify config.h as described in http://denislaprise.com/2008/02/20/libcurl-for-your-iphone/

    in lib/config.h:
    uncomment #undef HAVEGLIBC_STRERRORR
    uncomment #undef HAVEPOSIX_STRERRORR
    comment #define HAVESTRERRORR 1
  • Clea Rees Level 4 Level 4 (1,245 points)
    Thanks for saying thanks,
    cfr