0

I'm having trouble incorporating OpenSSL to my MacOS app for validating apple's receipt. Here's what I get:

dyld: Library not loaded: /usr/local/ssl/lib/libcrypto.1.0.0.dylib

Here's what I'm doing:

I'm using this script to compile my OpenSSL lib:

#!/bin/bash

OPENSSL_VERSION="1.0.1e"

curl -O -L http://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz
mv openssl-$OPENSSL_VERSION openssl_i386
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz
mv openssl-$OPENSSL_VERSION openssl_x86_64
cd openssl_i386
./Configure darwin-i386-cc -shared
make
cd ../
cd openssl_x86_64
./Configure darwin64-x86_64-cc -shared
make
cd ../
lipo -create openssl_i386/libcrypto.dylib openssl_x86_64/libcrypto.dylib -output libcrypto.dylib
lipo -create openssl_i386/libssl.dylib openssl_x86_64/libssl.dylib -output libssl.dylib
rm openssl-$OPENSSL_VERSION.tar.gz

Which gives me libssl.dylib and libcrypto.dylib

Then I run pod install with my podfile:

target 'MyApp' do
use_frameworks!
pod 'OpenSSL', '~> 1.0'
end

I then try to run my project just to get:

dyld: Library not loaded: /usr/local/ssl/lib/libcrypto.1.0.0.dylib
  Referenced from: /Users/me/Source/myApp/DerivedData/myApp/Build/Products/Debug/myApp.app/Contents/MacOS/myApp
  Reason: image not found

I understand I didn't add the librypto lib yet, but why does it try to find it in my /usr/local/ssl/lib/? Where should I place it?

Pawel Jurczyk
  • 165
  • 2
  • 10
  • You should probably add some of the `DYLD_PRINT_*` to debug the library loading issue; see the [`dyld(1)` man page](https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/dyld.1.html). If its just *"Reason: image not found"*, then use `install_name_tool` to change the location. The process to create the fat library appears to be off a bit. You need to ensure `opensslconf.h` is preserved for both i386 and x86_64; see [Build Multiarch OpenSSL on OS X](http://stackoverflow.com/q/25530429/608639). – jww Apr 26 '17 at 13:17
  • Here are some dups: [dyld: Library not loaded … Reason: Image not loaded](http://stackoverflow.com/q/17703510/608639), [install_name_tool to update a executable to search for dylib in Mac OS X](http://stackoverflow.com/q/33991581/608639), [Error: dlopen() Library not loaded Reason: image not found](http://stackoverflow.com/q/19776571/608639), etc. – jww Apr 26 '17 at 13:21

1 Answers1

0

Thank you for your comments, in the end I solved it by using a different pod OpenSSL-Universal

Pawel Jurczyk
  • 165
  • 2
  • 10