views:

182

answers:

4

I am working on a Cocoa application that uses FTP and SFTP transfers, and the best way I've found to accomplish this is by using libcurl. Now I'm pretty sure that Mac OS X does not ship with libcurl installed, and even if it did it most likely wasn't built with libssh, which I would also need.

The only solution I can come up with in my head is to ship my application with a pre-built version of libcurl. Create some kind of custom installer to check the users computer for libcurl and install the prebuilt version if necessary. Am I correct with this? Seems like there might be a better way.

...and if a custom installer is what I need, can anyone point me at a good tutorial?

+1  A: 

What makes you sure that OS X doesn't ship with libcurl?

$ locate libcurl
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/libcurl.2.dylib
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/libcurl.3.dylib
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/libcurl.4.0.0.dylib
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/libcurl.4.dylib
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/libcurl.dylib
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/libcurl.2.dylib
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/libcurl.3.dylib
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/libcurl.4.dylib
/Developer/SDKs/MacOSX10.6.sdk/usr/lib/libcurl.dylib

Either way, if you need your own, just put it in your bundle.

Azeem.Butt
Ok, so I guess it does. However the one on my machine isn't built with SFTP support. And what do you mean by 'put it in my bundle'?
nick
I mean put it in your bundle. http://developer.apple.com/mac/library/documentation/CoreFoundation/Conceptual/CFBundles/AboutBundles/AboutBundles.html#//apple_ref/doc/uid/10000123i-CH100-SW1
Azeem.Butt
+1  A: 

Now I'm pretty sure that Mac OS X does not ship with libcurl installed, …

Yes, it does:

curl --version                                                            %~(0)
curl 7.19.4 (universal-apple-darwin10.0) libcurl/7.19.4 OpenSSL/0.9.8k zlib/1.2.3

… and even if it did it most likely wasn't built with libssh, which I would also need.

Correct: It doesn't.

Protocols: tftp ftp telnet dict ldap http file https ftps 
Features: GSS-Negotiate IPv6 Largefile NTLM SSL libz 

You may find it simpler to build your libcurl as a static library, and link against that, than to build a shared library and copy it into your app's Frameworks subdirectory.

Peter Hosey
Sounds like this is what I need to do. Are there drawbacks to using a static library vs a dynamic one? Also I'm also not sure how to build or use static libraries but wouldn't a static lib file also have to live in my application's bundle?
nick
No to the last question; the link editor will integrate the contents of the static library into your executable.
Peter Hosey
+1  A: 

You can use install_name_tool to change the search path of dynamically linked libraries.

Using @executable_path you can use paths relative to your applications executable file and then place the libraries either in your frameworks folder ("@executable_path/../Frameworks/libcurl.dylib") or inside the executable directory (e.g. "@executable_path/lib/libcurl.dylib").

This way you can build your own dynamically linked libraries and ship them inside your application bundle.

Adrian
I've been doing some research the past couple days with building static/dynamic libraries and using the install_name_tool. All new concepts for me, but I finally got it working. I like this solution over Peter's because this will allow me to individually publish updates to my application and/or just the dylib file in my bundle. Thanks for the help!
nick
A: 

Maybe you want to have a look at ConnectionKit before using libcurl.

Norman
I found ConnectionKit's FTP support to be solid, however the SFTP support was very buggy. I'm comfortable writing C, and libcurl is quite impressive thus far.
nick
To add to my previous comment, ConnectionKit is also significantly slower than libcurl.
nick