De Tout Et De Rien

To content | To menu | To search

Thursday, May 6 2010

Building OpenSSL for iPhone

With the latest iPhone SDK 4.0 release, Apple has introduced the concept of fat binaries to the iPhone/iPad platform. Now, applications for these devices are built for both ARMv6 and ARMv7 architectures.

This has an impact on the third-party libraries you may choose to use, especially the one that don't come with a XCode project; OpenSSL is one of them. This post describes the basic steps to build an universal version of OpenSSL to target the development of iPhone/iPad applications.

Getting OpenSSL

The OpenSSL website only offers source code packages. Be sure to get the latest one, as the library is evolving quickly. At the time of writing, the latest version is the 1.0.0.

Once you got the archive, uncompress it where you want. Open a Terminal and go the uncompressed folder.

As we want to target all the architecture, we need THREE different builds: the simulator (i386), ARMv6 and ARMv7.

Patching OpenSSL

Open the ./crypto/ui/ui_openssl.c file and replace the line

static volatile sig_atomic_t intr_signal;

with

static volatile int intr_signal;

This is because the sig_atomic_t typedef does not exists for iPhone.

Building OpenSSL

Building for the simulator (i386)

Create a folder for the distribution, for example iPhoneSimulator-i386.

Launch the configuration:

./Configure BSD-generic32 --openssldir=iPhoneSimulator-i386

Now, edit the Makefile file and change:

CC= cc

CFLAG= -DOPENSSL_THREADS ...

with

CC= /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -arch i386

CFLAG= -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk -DOPENSSL_THREADS ...

Once, all this is done, build the OpenSSL:

make; make install

Building for iPhoneOS (ARMv6)

Create a folder for the distribution, for example iPhoneOS-armv6.

Launch the configuration:

./Configure BSD-generic32 --openssldir=iPhoneOS-armv6

Now, edit the Makefile file and change:

CC= cc

CFLAG= -DOPENSSL_THREADS ...

with

CC= /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv6

CFLAG= -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk -DOPENSSL_THREADS ...

Once, all this is done, build the OpenSSL:

make; make install

Building for iPhoneOS (ARMv7)

Create a folder for the distribution, for example iPhoneOS-armv7.

Launch the configuration:

./Configure BSD-generic32 --openssldir=iPhoneOS-armv7

Now, edit the Makefile file and change:

CC= cc

CFLAG= -DOPENSSL_THREADS ...

with

CC= /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv7

CFLAG= -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk -DOPENSSL_THREADS ...

Once, all this is done, build the OpenSSL:

make; make install

Merging OpenSSL

Now that you have the three distinct architecture, a simple way to use them is to merge them.

Create a folder for the distribution, for example iPhoneOS, and two subfolders iPhoneOS/include and iPhoneOS/lib.

Copy the include files from one of the distribution:

@@cp -R iPhoneOS-armv7/include/ iPhoneOS/include

Build a fat binary for each static library:

lipo -create iPhoneSimulator-i386/lib/libcrypto.a iPhoneOS-armv6/lib/libcrypto.a iPhoneOS-armv7/lib/libcrypto.a -output iPhoneOS/lib/libcrypto.a

lipo -create iPhoneSimulator-i386/lib/libssl.a iPhoneOS-armv6/lib/libssl.a iPhoneOS-armv7/lib/libssl.a -output iPhoneOS/lib/libssl.a

Conclusion

The iPhoneOS now contains all you need to develop OpenSSL application for iPhone/iPad.

Saturday, May 16 2009

How to use a MacBook in closed clamshell with an external display

It is very simple; just follow the instructions of this article:

But there is a gotcha: if you don't connect your MacBook to the power outlet, you will never be able to use the external display.

Wednesday, August 13 2008

Are you Vexed ?

If you like puzzle and you have an iPhone, you will like Vexed.

I have download it yesterday and I cannot stop myself from trying to solve all these puzzles (the site lists 1100 puzzles !!!). It is a must-have for any iPhone owner. Click to download on iTunes.

Thursday, March 13 2008

Never trust a computer you can't lift

"Today, I met an IBM mainframe. Never trust a computer you can't lift" (via Maceinstein)

Friday, February 15 2008

Time Machine Icon in Menu Bar

Since Mac OS X 10.5.2, there is a Time Machine Icon in the Menu Bar. Have you ever noticed that when a backup is in progress, the icon's clock goes backward ?

Wednesday, November 21 2007

What I really like about Mac OS X 10.5 (Leopard)

I recently successfully upgrade my MacBook to the new version of Mac OS X, also known as Leopard. After one hour, I had a ready to go system, without any problem.

I think Leopard is a great upgrade especially for:

  • The Finder is now very smart and responsive. The search is amazingly fast and QuickLook is very handy, especially on text documents and images.
  • Time Machine is one of the killer feature that makes backup a breeze. The initial backup is pretty long, but after that, it is very stealth. and the Time Machine animations are REALLY cool.
  • Spaces is very handy, and its integration is nicely done. Moving a window from a space to another space is simply as dragging and dropping .Maybe, an permanent overview of the spaces will be neat.
  • In Terminal, you can now have tabs, which reduces the screen pollution. Another feature long seen before in Linux.
  • And what I like, is that EVERYTHING seems to go faster than in Tiger. It is totally subjective.

So, my piece of advice is go and get it.

Tuesday, November 13 2007

Change the large size of dock icons

While testing the glass effect on the MacOS Dock on Leopard, I was suprised to see a curious parameter in com.apple.dock.plist. It is related to the large size of the dock icons when magnification is enabled. The preferences pane let you set this value to 128 at most, but you can put arbitrary value in the plist file.

defaults write com.apple.dock largesize -int 256
killall Dock

And your dock will show bigger icons. To revert to a normal size, open the Dock Preferences Pane.

Saturday, January 20 2007

Let's laugh about iPhone...

iPhone isn't out, but lots of things have been told on it. Here is one of my favourite.

Sunday, July 30 2006

Ejecter un CD/DVD coincé dans un MacBook/MacBook Pro

Alors que je voulais effacer un DVD réinscriptible avec l'Utilitaire de Disque de MacOS X, l'opération a lamentablement échouée. Soit. Mais, quelle ne fut pas ma surprise de constater que le DVD n'était pas éjectable. Nulle part il n'apparaissait et la touche d'éjection (F12) était inopérante. C'est alors que j'ai commis une erreur : redémarrer. Que faire d'autre me direz-vous ?

Sauf que quand mon MacBook a redémarré, il a commencé par essayer de booter sur le DVD, en boucle infinie. J'étais donc bloqué. Après une brève recherche sur Google, je consulte la fiche de support d'Apple sur le problème. Après plusieurs essais (réinitialisation de la PRAM et réinitialisation du gestionnaire d'alimentation), je me retrouve avec une brique. C'est alors que je trouve dans cette entrée le moyen de mettre fin à cet incident.

L'entrée étant en anglais, voici la procédure en français pour les interanautes confrontés au même problème et ne comprenant la langue de Shakespeare.

  1. Tout d'abord, il faut vous munir d'une languette de carton. J'ai pris un bout d'emballage de piles. Découpez-le pour en faire un morceau d'environ 8cm par 3cm.

  2. Eteignez votre MacBook/MacBook Pro en appuyant une dizaine de secondes sur le bouton marche/arrêt.
  3. Introduisez la languette de carton dans la fente du lecteur à peu près au milieu de la longueur.


    Enfoncez-la d'à peu près 2cm en l'inclinant pour faire en sorte qu'elle soit au dessus du disque.

  4. Allumez votre MacBook/MacBook Pro et cliquez sur le bouton du trackpad. Lorsque le CD/DVD se met à tourner, levez la languette pour bloquer la rotation du disque. Au bout de quelques secondes, le disque s'éjecte.

Bien sûr, je ne suis en aucun cas responsable de ce qui pourrait vous arrivez en appliquant la méthode décrite ci-dessus. A bon entendeur, salut.

Saturday, July 29 2006

Playing Windows Media Files with QuickTime player on Mac OS X

When you wanted to play Windows Media Files on MacOS X, the choice was pretty simple : use Windows Media Player for MacOS X.

But now, there is an alternate solution : you can now play Windows Media Files with Quicktime, thanks to the Windows Media Components for QuickTime. The components are based on the Flip4Mac engine and allow playing of the most of the Windows formats.

- page 1 of 2