Getting LibCurl to work on iOs...

Discussion in 'Game Development (Technical)' started by Raptisoft, Oct 26, 2010.

  1. Raptisoft

    Raptisoft
    Expand Collapse
    Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    804
    Likes Received:
    0
    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/articles/showArticle/index/use_curl_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. Nutter2000

    Nutter2000
    Expand Collapse
    Original Member Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    994
    Likes Received:
    2
    Not wanting to be the idiot asking stupid questions but why can't you just use NSURLConnection?

    Is it just a preference thing?
     
  3. Raptisoft

    Raptisoft
    Expand Collapse
    Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    804
    Likes Received:
    0
    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. Nutter2000

    Nutter2000
    Expand Collapse
    Original Member Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    994
    Likes Received:
    2
    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 :)
     
  5. Raptisoft

    Raptisoft
    Expand Collapse
    Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    804
    Likes Received:
    0
    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. Nutter2000

    Nutter2000
    Expand Collapse
    Original Member Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    994
    Likes Received:
    2
    Nice one :D
     
  7. UnknownGuy

    UnknownGuy
    Expand Collapse
    Original Member

    Joined:
    Mar 22, 2006
    Messages:
    104
    Likes Received:
    0
    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. Jamie W

    Jamie W
    Expand Collapse
    Original Member Indie Author

    Joined:
    Apr 16, 2006
    Messages:
    1,211
    Likes Received:
    0
    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. Raptisoft

    Raptisoft
    Expand Collapse
    Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    804
    Likes Received:
    0
    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. KlickTock

    KlickTock
    Expand Collapse
    New Member

    Joined:
    Jun 9, 2009
    Messages:
    22
    Likes Received:
    0
    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. Raptisoft

    Raptisoft
    Expand Collapse
    Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    804
    Likes Received:
    0
    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.
     

Share This Page