Here are the steps to get this working.
download the distribution of cURL you wish to use. I used this source file from apple
Download and unzip/untar your source code.
Open the terminal and change to the source directory.
The following command is what I used to compile this, on OS X 10.5.5, with the 2.1 iPhone SDK. You may make changes as desired.
./configure --host=arm-apple-darwin --program-prefix=/usr/local/iphone --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-gcc-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/Library/iPhone/include -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 AS=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/as LIBTOOL=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool STRIP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/strip RANLIB=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib
I think that the libtool line actually doesn't get used, the makefiles use something else in it's place, you can likely remove that portion of the above, but it doesn't hurt anything to leave it. There may be other things like this, but I'm not cool enough to know what's going on there.
One important thing to mention -- you need to use the --host keyword rather than the --build keyword because you are targeting a different architecture than what you are building the library on. This threw me off for a bit.
Once you run this command you should get a bunch of stuff going on and a sort of status screen at the end with a description of what options are on or off in the cURL library you are about to create.
leave the terminal open and go back to the finder, we want to be in the root directory of the folder you unzipped above. Open the lib directory and edit config.h. This file is auto-generated, but we need to change a few lines. Find the following lines and change accordingly:
uncomment #undef HAVE_GLIBC_STRERROR_R
uncomment #undef HAVE_POSIX_STRERROR_R
comment #define HAVE_STRERROR_R 1
Thanks to Denis Laprise
for help here.
now save this file and go back to the terminal.
type make and press return. This will compile the library. I was concerned when I did this and spent a few hours trying to figure out what I was doing wrong. You will se a number of ranlib errors about object files that are empty. However, not all object files are empty, this is due to turning off some of the options above. The library itself is built and ranlib is successful on the parts we were building.
This is where I stopped, but if you're more command-line savvy than I you could probably play around with "sudo make install" and get the results handed to you a bit better. I skipped that and grabbed the library to use with my project.
Assuming you used the library I linked, it is in curl-7.16.3/lib/.libs/libcurl.a and is ready to go. if you're still in the terminal you can change to that directory and type "open ." to have a finder window opened for you. Then copy the library to your project folder, along with the curl-7.16.3/include/curl/ directory containing your header files. Include these header files and this library in your project and you're good to go!
keep in mind that THIS WILL NOT WORK IN THE SIMULATOR. It is compiled for the iPhone arm processor and to get curl to work with the simulator you will need to change the paths and --host above in the configure call. I plan on making a copy of my curl source folder, rerunning configure with defaults (which should build for the current platform) and then include that library in my project for the simulator target only. I'll probably also rename the library so that I can tell them apart in the project.
Testing this wasn't too bad either. I used the default template utility iPhone application. Make sure to change the code signing properly so that it works on your device as well as the info.plist to contain your correct information. I used this code
to test out the curl library on the iPhone and simply stepped through it in the debugger to verify that it was working.
Thanks again to everyone who helped in this process. I hope this is useful for someone else!
I've been frustrated by the lack of ability to archive a webpage in a UIWebView when quitting your application to display when restarting it. I've looked around and there seems to be no official way to do this.
I've been looking at cURL and was thinking it would be nice but take me way too long to port this... however, after looking around I found the following path on my HDD:
It should be available with the SDK! Nice!
Except that I can't find the actual library to include to get this to happen. Nothing in apple's documentation, nothing that I can find in the frameworks or library. Has anyone used cURL with their app and can point me in the right direction? Is there a framework that includes support for this that I am unaware of?
Thanks in advance.