libcurl for iOS 7.30.0

Here's a precompiled binary of libcurl, its headers, and a sample app for iOS developers. (Since the command line of iOS is only available on jailbroken devices, it didn't make much sense to offer the command line tool here.) Separate libraries for the device and simulator are included, as are the headers.

libcurl is a developer library that works similarly to Apple's NSURLConnection URL loader, but offers many more protocols and has many more options. And it's also available for Android and QNX and many other platforms as well. Any version of Xcode with an iOS SDK is necessary to get it to work. All releases of Xcode 4.0 and later have come with iOS SDKs.

The sample app, iOScURL, shows how to do some simple operations, such as downloading data from a server, as well as more complicated operations, such as sending WebDAV commands to a WebDAV server.

If you're looking for documentation for libcurl, you can read it online here, or you can read the documentation for specific functions by reading the man pages for the functions in Xcode or your favorite man page reader. OS X comes with libcurl, so the man pages are already installed on your Mac.

IMPORTANT: If you downloaded and used my previous builds of libcurl, which were for version 7.29.0, then you should upgrade to this build right away. Versions 7.29.0 had a security hole in its cookie handling code.

How to use the headers & libraries in your own project:

  1. Copy the "curl" directory, which includes the headers, into a place in your project's header search paths, such as the root directory of your project's source code.
  2. Copy the two static libraries from the sample code into your project. Where they are placed is up to you.
  3. You must link the project to the Security framework and the libz library. I also recommend you link the project to the CFNetwork library so you can read the device's proxy settings and use them to initialize proxy support in libcurl.
  4. If you did all of the above and it's still not linking, you may need to run ranlib on the archives once in order to update their TOCs.

What features are included in these pre-compiled binaries:

What features aren't included:

The device library is built for armv7 and armv7s, and therefore requires an iPhone 3GS or later, or iPod touch 3 or later, or any iPad. Both libraries are compiled against the iOS 6 SDK, but were built with a deployment target of 4.3. SSL and TLS require iOS 5 or later, since Secure Transport did not become public API until iOS 5 was released.

As far as I know, neither binary includes any actual cryptography or digest-generating code. It uses the Security framework and CommonCrypto library for all of its cryptography and digest-generation needs. And CommonCrypto is a part of the standard C library on iOS and OS X.

If you need support, then please ask on the curl-library mailing list, where libcurl users or developers can help you.

How to build libcurl (or any other project that uses GNU Autotools) for iOS

I've had some people ask me how I built libcurl for iOS. Unfortunately a lot of the information currently on the Web on how to build projects that use GNU Autotools for build configuration on iOS is obsolete, because the compilers, paths, and build architectures for iOS binaries have all been changed in newer versions of Xcode. Here is what I use on Xcode 4.6.x to build for the device:

$ export IPHONEOS_DEPLOYMENT_TARGET="4.3"
$ export CC="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2"
$ export CFLAGS="-arch armv7 -arch armv7s -pipe -Os -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk"
$ export LDFLAGS="-arch armv7 -arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk"
$ ./configure --disable-shared --enable-static --disable-dependency-tracking --host="armv7-apple-darwin" --prefix=[PREFIX] [OTHER_BUILD_FLAGS]
$ make -j `sysctl -n hw.logicalcpu_max`

...where you substitute [OTHER_BUILD_FLAGS] for the other configuration flags you want to pass to the configure script, and [PREFIX] for the path to place the final product when running "make install". (It is an exceptionally bad idea to install cross-compiled binaries into Autotools' default prefix path, /usr/local.) Note that you don't need to run "make install" if you don't want to do that. You can just run a regular build, and then copy the built library from out of the ./lib/.libs folder. (The folder location varies from project to project, but that's where the curl project places its built products.)

Building for the simulator is a little bit different:

$ export IPHONEOS_DEPLOYMENT_TARGET="4.3"
$ export CC="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2"
$ export CFLAGS="-arch i386 -pipe -Os -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk"
$ export CPPFLAGS="-D__IPHONE_OS_VERSION_MIN_REQUIRED=${IPHONEOS_DEPLOYMENT_TARGET%%.*}0000"
$ export LDFLAGS="-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk"
$ ./configure --disable-shared --enable-static --host="i386-apple-darwin" --prefix=[PREFIX] [OTHER_BUILD_FLAGS]
$ make -j `sysctl -n hw.logicalcpu_max`

Note the CPPFLAGS variable above. If you don't set this as described, then the compiler will think you're building for OS X instead of iOS, and it'll use the incorrect availability macros when reading the SDK headers (oops!).

There's one more thing: If you're using a newer version of Xcode than 4.6, then you will also need to change the iOS SDK version in the path to whichever version of the SDK came with your version of Xcode.

Download libcurl for iOS 7.30.0

Back to Nick's Software Page