Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking to libcrypto for Leopard?

I am using Mac OS X 10.6 SDK and my deployment target is set to Mac OS 10.5. I'm linking to libcrypto (AquaticPrime requires this) and found out that my app doesn't launch on Leopard. The error is

dyld: Library not loaded: /usr/lib/libcrypto.0.9.8.dylib

I've tried the following workarounds but none of them work:

  • Linking directly to libcrypto.0.9.7.dylib (the 10.6 SDK refuses to link directly with libcrypto.0.9.7.dylib.
  • Copying the 10.5 SDK's version of libcrypto.0.9.7.dylib to the 10.6 lib directory and try t link with it (this time the link process succeeded but in Leopard the app still tries to lookup the non-existent libcrypto.0.9.8.dylib file and thus won't launch).
  • Copying libcrypto.0.9.7.dylib from a Mac OS X 10.5.8 installation and link with it (the link was successful but the app still looks for libcrypto.0.9.8.dylib).

Is there a way to link to this library and still use the 10.6 SDK?

Thanks.

like image 645
adib Avatar asked Apr 11 '10 10:04

adib


3 Answers

As per this thread here ( first post in thread: http://lists.apple.com/archives/cocoa-dev/2009/Aug/msg01737.html , "libcrypto on Snow Leopard" thread listing: http://lists.apple.com/archives/cocoa-dev/2009/Aug/thrd19.html ), I believe the solution is to do the following:

  1. Go to /Developer/SDKs/MacOSX10.5.sdk/usr/lib/ . From this folder, copy "libcrypto.0.9.7.dylib" to your project source folder.

  2. Rename the file you just copied to "libmycrypto.dylib".

  3. Add the file you just renamed to your project. Make sure to remove any other linked libcrypto frameworks from your project.

  4. Go through your build settings, and make sure you remove the "-lcrypto" linker flag. (It's usually put in the "Other Linker Flags" setting.)

Now you should be able to build your project and it will work on both 10.5 and 10.6.

(libcrypto.0.9.7 is available on both 10.5 and 10.6. The file you copied is just a stub of the headers, but you're just linking against it, not embedding it in your project. Since the linker uses the install path not the actual filename of the dylib, naming it "libmycrypto.dylib" eliminates path conflicts, but still allows you to link against the library you need.

FWIW, this is an Xcode problem. You should be able to link against /usr/lib/libcrypto.dylib -- the symbolic link -- and have it target the correct version of libcrypto on both 10.5 and 10.6. However, Xcode always seems to link to version 0.9.8 when building on Snow Leopard for some reason.)

like image 65
Simone Manganelli Avatar answered Nov 14 '22 00:11

Simone Manganelli


You could try setting the base SDK to 10.5 in your target build settings.

like image 40
JeremyP Avatar answered Nov 13 '22 23:11

JeremyP


Depending on what you're using the lib for, you might be able to replace libcrypto with CommonCrypto which works well with both 10.5 and 10.6. I've used libcrypto only for the MD5 function, so I replaced openssl/md5.h with CommonCrypto/CommonDigest.h and MD5() with CC_MD5(), and libcrypto with CommonCrypto, and now it works on both Leopards.

like image 1
Kuba Suder Avatar answered Nov 13 '22 22:11

Kuba Suder