1

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?

nrj
  • 1,701
  • 2
  • 22
  • 37

4 Answers4

2

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
  • 95,783
  • 15
  • 211
  • 370
  • 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? – nrj Dec 27 '09 at 21:53
  • No to the last question; the link editor will integrate the contents of the static library into your executable. – Peter Hosey Dec 27 '09 at 22:29
2

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
  • 994
  • 5
  • 5
  • 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! – nrj Dec 30 '09 at 06:22
  • hi nick, i have a problem like this, can you tell me how you solved this, and maybe can you give me the example about using install_name_tool? thank you – R. Dewi May 31 '11 at 03:31
1

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
  • 5,855
  • 1
  • 26
  • 22
  • 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'? – nrj Dec 27 '09 at 05:06
  • 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 Dec 27 '09 at 06:01
0

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

Norman
  • 106
  • 1
  • 5
  • 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. – nrj Dec 27 '09 at 21:19
  • To add to my previous comment, ConnectionKit is also significantly slower than libcurl. – nrj Dec 27 '09 at 21:26