Results 1 to 11 of 11

Thread: Getting LibCurl to work on iOs...

  1. #1

    Default Getting LibCurl to work on iOs...

    Hi all,
    Does anyone have any experience getting LibCurl working on iPhone OS? I implemented the static library solution found here: http://www.intelliproject.net/articl...url_iphone_sdk ... but whenever I try to upload a file, I get a "host can't be resolved" error.

    So I wanted to see if anyone has any tips. If you have a good deal of experience, and can just take an XCode project away, out of my site, get it out of here, and make it all work beautifully and send it back, I'm willing to paypal money.

    Thanks,
    John

  2. #2

    Join Date
    Jul 2004
    Location
    Nottingham, UK
    Posts
    971

    Default

    Not wanting to be the idiot asking stupid questions but why can't you just use NSURLConnection?

    Is it just a preference thing?
    Iain Key - Blog - Twitter - LinkedIn - Facebook
    All Out War: 4025 - Ferion - Hail of Bullets Software

  3. #3

    Default

    Yes. I have a libcurl interface that works perfectly on Windows, does exactly what I want it to do, and, most importantly, is in C++, and I don't want to spend the time trying to figure out the crazy Objective-C equivalents to things I already know.

  4. #4

    Join Date
    Jul 2004
    Location
    Nottingham, UK
    Posts
    971

    Default

    Fair enough, it might be easier than trying to statically link libCurl though
    I came pretty much the same route C++ & PHP to Objective C and it's not that difficult.

    ...but it's your choice of course
    Iain Key - Blog - Twitter - LinkedIn - Facebook
    All Out War: 4025 - Ferion - Hail of Bullets Software

  5. #5

    Default

    After 8 hours, I got it working, heh.

    I hope I never have to do anything technical on the Apple platform again. On Windows, you google this stuff and there's your answer. On Apple (iOS at least) each version of XCode is so different that anything on the web is out of date.

  6. #6

    Join Date
    Jul 2004
    Location
    Nottingham, UK
    Posts
    971

    Default

    Nice one
    Iain Key - Blog - Twitter - LinkedIn - Facebook
    All Out War: 4025 - Ferion - Hail of Bullets Software

  7. #7

    Default

    If there was a likely repeatable cause, you should post it here so the next person who Google's it doesn't need to spend 8 hours.

  8. #8

    Default

    I had a go some time back, trying to get libCurl working on iOS. Had to give up in the end..

    NSURLConnetion was fine for my purpose, and managed to wrap up everything I needed in to a C++ class (so can access from C++ files etc).

    Congrats on getting it to work though; how's perfermance and reliability? Any glitches or lost data etc?

  9. #9

    Default

    It seems to work okay. The whole issue was getting the makefile to correctly... after I did that, everything was a breeze.

    I documented the steps I had to use to do it... here's my notes, which are idiotproof for me (I tend to write things down step by step so I don't have to do any thinking when I redo it years later and don't remember anything):

    Code:
    To make LibCurl, download the library onto the desktop, make a results folder on the desktop, then Terminal to the libcurl folder and type these:
    
    export CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2
    export CFLAGS="-arch armv6 --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk"
    export CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp
    export AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar
    
    ./configure --prefix=/Users/[yourname]/Desktop/results --host=arm-apple-darwin --disable-ldap --without-zlib --without-ca-bundle --without-ca-path --disable-shared --enable-static --with-random=/dev/urandom --without-ssl
    
    make
    make install
    
    In the results folder, use the /include folder, and the libcurl.a file from the lib folder.

  10. #10

    Join Date
    Jun 2009
    Location
    Edenhope, Victoria, Australia
    Posts
    22

    Default

    Necro!

    Hey John and friends. Thanks so much for putting this thread together. After banging my head on a brick wall for 12 hours trying to get Libcurl to run on iPhone, yours was the one that got me the closest. However, I though - for the sake of anyone else trying this - I should post up my solution here which I cobbled together from various sources.

    I wanted to build a universal library for ArmV6, ArmV7 and i386. Finally got it going earlier.

    Code:
    // ARMV7
    export CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2
    export CFLAGS="-arch armv7 --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk"
    export CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp
    export AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar
    ./configure --disable-shared --without-ssl --without-libssh2 --without-ca-bundle --without-ldap --disable-ldap --host=arm-apple-darwin10
    make clean
    make
    ar rv libcurl.armv7.a lib/*.o
    Code:
    // ARMV6
    export CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2
    export CFLAGS="-arch armv6 --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk"
    export CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp
    export AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar
    ./configure --disable-shared --without-ssl --without-libssh2 --without-ca-bundle --without-ldap --disable-ldap --host=arm-apple-darwin10
    make clean
    make
    ar rv libcurl.armv6.a lib/*.o
    Now, for some reason I had to exit terminal before I built the i386 version, or the compiler was crapping itself.

    Code:
    // i386 (SIMULATOR)
    export CC=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2
    export CFLAGS="-arch i386 --sysroot=/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk"
    export CPP=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/cpp
    export AR=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ar
    ./configure --disable-shared --without-ssl --without-libssh2 --without-ca-bundle --without-ldap --disable-ldap --host=i386-apple-darwin10
    make clean
    make
    ar rv libcurl.i386.a lib/*.o
    Finally I used lipo to glue them all together in one .a file.

    Code:
    lipo -create libcurl.armv7.a libcurl.armv6.a libcurl.i386.a -output libcurl.a

  11. #11

    Default

    Hey Klicktock,
    Here it is, about a year later, and with changes Apple has made, I am unable to compile LibCurl for iOS5 using EITHER of our solutions above.
    You wouldn't happen to have your .a file around, would you? Any chance I can beg it off you? My compile only works for Arm6.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •