`
yangwei0915
  • 浏览: 460351 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

[转] How To Compile OpenSSL for the iPhone

阅读更多

This is a quick tutorial to show you how to minimally compile a version of the openssl and crypto libraries for the iPhone/iPad.

Download and Configure OpenSSL

First thing to do is grab the openssl source.  You can get that here.  I’ll be using openssl-1.0.0 for this demo.  Unzip this file (mines on the desktop).  Open up a terminal and go to the unzipped folder and run the default configuration.  The argument passed is where your ‘make install’ will place the compiled libraries. You should replace this with your path.

cd Desktop/openssl-1.0.0
./config --openssldir=/Users/airpard/Desktop/openssl_ios/ no-asm

* Note if you want a simulator build you should do a regular make; make install at this point. The following steps are for armv6 and armv7 using the latest v4.2 iOS environment.

Edit the Makefile

Next thing to do is open up the make file.  This is named “Makefile” in the current directory you should already be in with the terminal.  Here are the list of changes to make (for armv7, replace armv6 references below):

Find CC= cc and change it to:
CC= /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2
 
Find -arch i386 in CFLAG and change it to:
-arch armv6
 
Find CFLAG and add to the BEGINNING!!:
-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk
 
Find SHARED_LDFLAGS=-arch i386 -dynamiclib and change it to:
SHARED_LDFLAGS=-arch armv6 -dynamiclib
 
Find PEX_LIBS= -Wl, -search_paths_firstxc and change it to:
PEX_LIBS= -Wl

Fix Build Error

If you build it at this point you may have noticed a build error. To fix this open up ui_openssl.c. This is located in openssl-1.0.0/crypto/ui/ folder. If you have a text editor with line numbers, head down to line 407. Otherwise do a text search to make this change:

static volatile sig_atomic_t intr_signal;
to
static volatile int intr_signal;

Save your changes and you should now be able to build with no errors.

Build Libraries

make
make install

That’s it. You’ll notice that everything was moved to the path provided in step 1 when configuring openssl. Remember to add the include folder to your Xcode project. Also, remember these libraries are only built for the iPhone and will not work in the simulator. You can change all the armv6 references to i386 and build it again if you choose to. Happy Coding!

 

找到build_all: build_libs build_apps build_tests build_tools(大概在242行)
修改为build_all: build_libs build_apps build_tools

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics