Statically link OpenSSL in XCode -


i trying link libssl.a , libcrypto.a static libraries in xcode command line project [under link binary libraries]. have included openssl header files in search path.

compilation succeeds execution fails dyld: library not loaded: /usr/local/ssl/lib/libcrypto.1.0.0.dylib.

why dylib when linking statically? how can fixed?

any appreciable.

why dylib when linking statically? how can fixed?

apple's linker uses dylib or share object if available, regardless of of linker flags -rpath , -bstatic. on ios, dylib's not allowed!

its kind of known problem once know :) see, example, installing crypto++ 5.6.2 on mac os x. crypto++ has same problems apple's tools.

the fix stop using -l , -l options, , link object file or archive directly. archive collection of object files, can use them interchangeably.

to specify object files or archives linker, see linking object file. under xcode, add specified archive name (like /usr/local/openssl-ios/lib/libcrypto.a) other linker flags (the other_ldflags xcode option).

when adding full archive other_ldflags, believe add verbatim without switches, -l or -l. may need -wl (-wl,/usr/local/openssl-ios/lib/libcrypto.a), don't use -l (-l/usr/local/openssl-ios/lib/libcrypto.a).

you use -wl when option passed through compiler driver linker. if linker invoked directly, don't need -wl , should not use it.


a second option set gcc_link_with_dynamic_libraries yes. apple not appear document in xcode build setting reference, under copy of xcode. see how link static library ios on stack overflow.

i seem recall having problems in past. 1 of things should work in theory, not work in practice.


a third option remove dylib or shared object paths used under xcode xcode not accidentally find when using -lcrypto.


a fourth option use allow dynamic linking, execute program dyld_library_path. os x's equivalent ld_library_path, , ensures copy of openssl loaded (like 1.0.2), , not system's version of openssl (0.9.8).

but don't option because requires users of software something.


another possibility due message dyld: library not loaded: /usr/local/ssl/lib/libcrypto.1.0.0.dylib code sign copy of library. little odd found not loaded, i'm going toss out there in case os x's code signing or gatekeeper service...

to code sign copy of library under mac developer program, just:

codesign -fs "johnny developer" /usr/local/ssl/lib/libcrypto.so 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -