Monday, November 16, 2015

OpenSSL Library with iOS 4.2

Create OpenSSL Libary:
  • Download OpenSSL Sourcecode
  • Build OpenSSL for i368 iPhoneSimulator:
    • cd openssl-1.0.0c
      mkdir openssl_arm
      mkdir openssl_i386
      ./config --openssldir=/Users/<username>/openssl-1.0.0c/openssl_i386
    • Edit Makefile:
      • Change CC = cc to:
        CC= /Developer/usr/bin/gcc-4.2
      • Add as first item to CFLAG:
        -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk
    • Change in crypto/ui/ui_openssl.c
      static volatile sig_atomic_t intr_signal;
      to
      static volatile int intr_signal;
      for preventing building error
    • Build it:
      make
      make install
    • Your libcrypto.a and libssl.a are in the folder openssl_i368/lib
    • Rename the two files to libcrypto_i386.a and libssl_i386.a
  • Build OpenSSL for arm iPhoneOS:
    • mv openssl_i386 openssl_i386_lib
      make clean
    • Edit Makefile:
      • Search and replace openssl_i386 with openssl_arm
      • Change -arch i386 in CFLAG to:
        -arch armv6
      • Change
        CC=  /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2
        to
        CC=  /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2
      • Change
        -isysroot  /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk
        to
        -isysroot  /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk
    • Build it:
      make
      make install
    • Your libcrypto.a and libssl.a are in the folder openssl_armv6/lib
    • Rename the two files to libcrypto_armv6.a and libssl_armv6.a

  • Build OpenSSL for armv7 iPhoneOS:
    • mv openssl_armv6 openssl_armv6_lib
      make clean
    • Edit Makefile:
      • Search and replace openssl_armv6 with openssl_armv7
      • Change -arch armv6 in CFLAG to:
        -arch armv7
    • Build it:
      make
      make install
    • Your libcrypto.a and libssl.a are in the folder openssl_armv7/lib
    • Rename the two files to libcrypto_armv7.a and libssl_armv7.a