问题
I have a project referenced to libSSL.a in xcode 5,so I try to build it myself.
error message of make
command is this:
What I have done:
1, Download and install Command Line Tools (download from here)
2, Download source code from openssl.net ,4509212 Jan 6 15:39:19 2014 openssl-1.0.1f.tar.gz (MD5) (SHA1) (PGP sign) [LATEST]
3, Change file crypto/ui/ui_openssl.c
from static volatile sig_atomic_t intr_signal;
to static volatile int intr_signal;
4, Make Dirs with command:
mkdir ssllibs
cd openssl-1.0.0a
mkdir openssl_armv6 openssl_armv7 openssl_i386
5, Configure:
./configure BSD-generic32 --openssldir=/Users/ccnyou/openssl-1.0.0a/openssl_i386
6, Edit Makefile
, CC= gcc
to CC= gcc -arch i386
7, Add this after CFLAG
-isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk
(may be wrong here)
8, make
, just get error messages like I mentioned above.
I wonder if it is the clangs and ar's compatibilty problems ? How to build libssl.a ? I'll be appreciated to anyone who give me suggestions for it.
回答1:
What I have done: 1, Download and install Command Line Tools (download from here) 2, Download source code from openssl.net ,4509212 Jan 6 15:39:19 2014 openssl-1.0.1f.tar.gz (MD5) (SHA1) (PGP sign) [LATEST] 3, Change file crypto/ui/ui_openssl.c from static volatile sig_atomic_t intr_signal; to static volatile int intr_signal; 4, Make Dirs with command: ...
OpenSSL has instructions for building for iOS. The instructions include a build script to set the environemnt so the proper target is set. You can find the instructions in the OpenSSL FIPS User Guide 2.0, Appendix E.2.
If you don't want to go through the step-by-step guide, try out this Github account. Its got OpenSSL pre-built for iOS 6.0 and 7.0 (arch ARMv7, ARMv7s, i386, and ARM64) for OpenSSL 1.0.1e and 1.0.1f. The Github offering also offers the script to set the environment.
(Sorry about the link answers. There's no way to digest all the information into a couple of paragraphs).
回答2:
I encourage you to use Cocoapods in your project, then you can easily use pod 'OpenSSL-Universal'
to have OpenSSL linked.
If you want to build it by yourself look at this script https://github.com/krzak/OpenSSL/blob/master/build.sh it might help you a lot.
来源:https://stackoverflow.com/questions/22538061/how-to-build-libssl-a-for-ios-from-source-code