{"id":59,"date":"2010-12-09T19:58:44","date_gmt":"2010-12-09T19:58:44","guid":{"rendered":"http:\/\/notsolazymoms.com\/blog\/2010\/12\/09\/building-libcurl-ios-42\/"},"modified":"2010-12-09T19:58:44","modified_gmt":"2010-12-09T19:58:44","slug":"building-libcurl-ios-42","status":"publish","type":"post","link":"https:\/\/creativealgorithms.com\/blog\/content\/building-libcurl-ios-42\/","title":{"rendered":"Building libCURL for iOS 4.2"},"content":{"rendered":"<p>I recently had to rebuild libCURL for iOS4.2 because I was getting crashes in the simulator related to libCURL which were not present in iOS4.1:<br \/>\n<code><br \/>\nDetected an attempt to call a symbol in system libraries that is not present on the iPhone:<br \/>\nclose$UNIX2003 called from function Curl_getaddrinfo in image TripBoss.<br \/>\nIf you are encountering this problem running a simulator binary within gdb, make sure you 'set start-with-shell off' first.<br \/>\nProgram received signal:  \u201cSIGABRT\u201d.<br \/>\n<\/code><\/p>\n<p><!--more--><br \/>\nI recently had to rebuild libCURL for iOS4.2 because I was getting crashes in the simulator related to libCURL which were not present in iOS4.1:<br \/>\n<code><br \/>\nDetected an attempt to call a symbol in system libraries that is not present on the iPhone:<br \/>\nclose$UNIX2003 called from function Curl_getaddrinfo in image TripBoss.<br \/>\nIf you are encountering this problem running a simulator binary within gdb, make sure you 'set start-with-shell off' first.<br \/>\nProgram received signal:  \u201cSIGABRT\u201d.<br \/>\n<\/code><\/p>\n<p>Unfortunately, adding &#8220;set start-with-shell 0&#8221; to ~\/.gdbinit did not rectify the problem and as <a href=\"http:\/\/www.un4seen.com\/forum\/?topic=10910.msg83921#msg83921\">this<\/a> forum post eludes to, the library needed to be rebuild without the $UNIX2003 symbol decoration.<\/p>\n<p>So, here is the procedure I am using to build libCURL without SSL (since SSL may require export restrictions).  Thanks to <a href=\"http:\/\/www.iphonedevx.com\/?p=49\">Silviu Caragea<\/a> and <a href=\"http:\/\/stoulouse.blogspot.com\/2008\/10\/libcurl-on-iphone.html\">Sam le Pirate<\/a> for leading the way.<\/p>\n<p>Download CURL source from: http:\/\/curl.haxx.se\/download.html<br \/>\n<code><br \/>\ntar -xvzf curl-7.21.2.tar.gz<br \/>\ncd curl-7.21.2<br \/>\nexport CC=\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/usr\/bin\/arm-apple-darwin10-gcc-4.0.1<br \/>\nexport CFLAGS=\"-isysroot \/Developer\/Platforms\/iPhoneOS.platform\/Developer\/SDKs\/iPhoneOS4.2.sdk\"<br \/>\nexport LDFLAGS=\"-isysroot \/Developer\/Platforms\/iPhoneOS.platform\/Developer\/SDKs\/iPhoneOS4.2.sdk -Wl,-syslibroot \/Developer\/Platforms\/iPhoneOS.platform\/Developer\/SDKs\/iPhoneOS4.2.sdk\"<br \/>\nexport CPP=\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/usr\/bin\/cpp<br \/>\n.\/configure --disable-shared --without-ssl --without-libssh2 --without-ca-bundle --without-ldap --disable-ldap --host=arm-apple-darwin10<br \/>\n<\/code><br \/>\nBy configuring with isysroot and syslibroot set the correct SDK, the CURL_SIZEOF_LONG and SIZEOF_LONG will get set to the correct value (4).<\/p>\n<p>In Xcode, choose File->New Project->iOS->Library->Cocoa Touch Static Library.<br \/>\nAdd->Existing Files (select curl&#8217;s &#8220;src&#8221; folder)<br \/>\nAdd->Existing Files (select curl&#8217;s &#8220;lib&#8221; folder)<br \/>\nRemove &#8220;src\/macos&#8221; folder from project. (Delete->Delete references)<br \/>\nUnselect Makefile and Makefile.inc checkboxes for target.<\/p>\n<p>In \u201cBuild\u201d tab search for OTHER_CFLAGS and add the following options:<br \/>\n<code><br \/>\n\t-DHAVE_CONFIG_H -I\/ca\/dev\/code\/lib\/curl\/curl-latest\/include -I\/ca\/dev\/code\/lib\/curl\/curl-latest\/lib<br \/>\n<\/code><br \/>\nReplace \/ca\/dev\/code\/lib\/curl\/curl-latest with the path at which you untarred the CURL source.<br \/>\nBuild both Simulator\/Release and Device\/Release.<\/p>\n<p>To make a universal library for both the simulator and the device, execute lipo from the command line of the Xcode project folder:<br \/>\n<code><br \/>\nlipo -create build\/Release-iphonesimulator\/libcurl.a build\/Release-iphoneos\/libcurl.a -output libcurl.a<br \/>\n<\/code><\/p>\n<p>The last step is to add libCURL to your app by right-clicking (or option-clicking) Frameworks->Add->Add Existing Frameworks&#8230;->Other and choosing the libCURL.a file created by lipo.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently had to rebuild libCURL for iOS4.2 because I was getting crashes in the simulator related to libCURL which were not present in iOS4.1: Detected an attempt to call a symbol in system libraries that is not present on the iPhone: close$UNIX2003 called from function Curl_getaddrinfo in image TripBoss. If you are encountering this&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[83],"class_list":["post-59","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-iphone-ipad-curl-networking-static-library-xcode"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/creativealgorithms.com\/blog\/wp-json\/wp\/v2\/posts\/59","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/creativealgorithms.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/creativealgorithms.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/creativealgorithms.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/creativealgorithms.com\/blog\/wp-json\/wp\/v2\/comments?post=59"}],"version-history":[{"count":0,"href":"https:\/\/creativealgorithms.com\/blog\/wp-json\/wp\/v2\/posts\/59\/revisions"}],"wp:attachment":[{"href":"https:\/\/creativealgorithms.com\/blog\/wp-json\/wp\/v2\/media?parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/creativealgorithms.com\/blog\/wp-json\/wp\/v2\/categories?post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/creativealgorithms.com\/blog\/wp-json\/wp\/v2\/tags?post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}