cloud goes social

Icon

computer, travel, movies, music, cuisine and more

Android kernel compilation, detailed instructions

Disclaimer

I am not responsible if anything goes bad. Ever. In particular if your devices will be unusable after following this tutorial! Mine didn’t :)

Introduction

I’ve recently been involved in making some changes to the Linux kernel. Not any Linux kernel but the Android Linux Kernel. I’ll share what I believe is a pretty good workflow for everyone interested in playing with it both on a NexusOne (with the stock OS, i.e. WITHOUT CyanogenMod) and on a HTC Magic (with CyanogenMod installed). They are quite similar scenarios, and many others have been writing about it. I always had to change a few things from others descriptions and therefore here I report what I found to be a working solution for the latest patched updated versions. This is an aggregation work of others spread all around the interwebs. I like things accessible in one place :)

Throughout this “tutorial” I will be assuming that you are working on a Linux environment (i.e. Ubuntu). Furthermore I work on a 32-bit system, if you are not in this situation try it out, but further changes might be needed.

Preliminary Settings

Let’s start with having all the necessary software which we will need later installed and operative. If you are already an Android and/or a Kernel developer you most probably have this already done. Skip this section.

  1. adb is needed. Install the latest Android SDK – I personally install it in
    ~/Bin/android-sdk-linux_x86

    Remember to add the tools/ directory to your $PATH variable.

  2. ndk is needed. Install the latest Android NDK – I personally install it in
    ~/Bin/android-ndk-VERSION

    For example the latest is version r5 and the directory will be:

    ~/Bin/android-ndk-r5

    . Remember then to add the toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin directory that is present inside the ndk to your $PATH variable.

  3. fastboot is needed. Grab it and download it inside your sdk/tools directory or anywhere that is in your $PATH
  4. Software is needed. Install it.
    apt-get install git-core gnupg sun-java6-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
    

    If you are on a 64-bit machine also install:

    apt-get install ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib
    

In the end your ~/.bash_profile, ~/.bash_rc, … would look along the lines of:

export PATH="~/Bin/android-sdk-linux_x86/tools:~/Bin/android-ndk-r5/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin:${PATH}"

Now let’s dwell into the interesting things. First of all have your directory structure well planned ahead. Or you will end up losing a lot of time just remembering what is what.

mkdir ~/android
mkdir ~/android/bootimg_builder
cd ~/android

Now we clone the git repositories for the Google kernel and for the CyanogenMod kernel. We will have two directories with the sources for the two kernels: cm-kernel and google-kernel

git clone git://github.com/CyanogenMod/cm-kernel.git cm-kernel
git clone git://android.git.kernel.org/kernel/msm.git google-kernel

This is where I will first go into explaining the procedure for the HTC Magic with CyanogenMod installed and afterwards I will explain how to make it work for the NexusOne.

HTC Magic with CyanogenMod

Let’s start by switching to our own branch, in case we want to modify anything and keep track of the changes without polluting the master branch. The latest CyanogenMod (6.1) uses the kernel version 2.6.35, we keep on using that.

cd cm-kernel
git checkout -b personal_branch origin/android-msm-2.6.35-froyo-stable

Now we need to pull the configuration file off from the device, have it plugged to the PC through the USB port.

adb pull /proc/config.gz config.gz
gunzip config.gz && mv config .config

Now we update the .config that will be used while compiling the kernel.

ARCH=arm CROSS_COMPILE=arm-eabi- make oldconfig
ARCH=arm CROSS_COMPILE=arm-eabi- make menuconfig

The last command will open up an interactive menu. Change what you want (i.e. nothing if you don’t require particular stuff…) and then get to Exit (and select Yes if you changed something, if you didn’t you won’t be prompted).

It is time to actually compile the kernel.

ARCH=arm CROSS_COMPILE=arm-eabi- make

The first time this will be a long procedure, the resulting file will be stored in

arch/arm/boot/zImage

and you can test it on your device directly by going into fastboot mode (hold the BACK button while powering up the device). Then issue this command:

fastboot boot arch/arm/boot/zImage

The phone should boot up normally and you can confirm that it’s running your kernel by going into Settings-About-Scroll down to the Kernel section. Note that if you reboot the phone it will go back to using the pre-installed kernel. More on flashing the kernel later on.

NexusOne with standard Android OS

First we need to unlock the NexusOne to accept new roms to be installed, have it in fastboot mode by holding the TRACKBALL down while booting up and issue this command

fastboot oem unlock

Note that this will void your warranty!

We also need the NexusOne to be rooted: rooting goes beyond the scope of this tutorial. Have your phone rooted in any way that you want (i.e. by using the SuperOneClick tool (it requires a Windows machine or luck with a Linux one).

This one is much more interesting! And while being very similar it also has some differences. First of all from our ~/android/ directory let’s move to the google-kernel directory and again create our own branch to work on.

cd ~/android/google-kernel
git checkout -b personal_branch origin/android-msm-2.6.32

Note that in this case we’re using the kernel version 2.6.32 which is the one that’s installed by default on the NexusOne. The latest 2.6.35 should work but I haven’t really tested.

Next we create the usual .config file

ARCH=arm CROSS_COMPILE=arm-eabi- make mahimahi_defconfig
ARCH=arm CROSS_COMPILE=arm-eabi- make menuconfig

Hit Exit and save if prompted (you shouldn’t!)

We now manually modify the .config file with your favorite text editor open the file and search for these strings

nano .config
uncomment CONFIG_USB_ANDROID_ACM=y (add the =y part and remove what's there)
comment CONFIG_MSM_SERIAL_DEBUGGER
comment CONFIG_MSM_FIQ_SUPPORT

We’re ready to compile the kernel

ARCH=arm CROSS_COMPILE=arm-eabi- make

This will take some time, the resulting product will be stored in arch/arm/boot/zImage and you can test it on your device directly by going into fastboot mode (hold the TRACKBALL down while powering up the device). Then issue this command:

fastboot boot arch/arm/boot/zImage

The phone should boot up normally and you can confirm that it’s running your kernel by going into Settings-About-Scroll down to the Kernel section. Note that if you reboot the phone it will go back to using the pre-installed kernel. More on flashing the kernel later on.

NexusOne enable my WiFi, please

The WiFi kernel module that is on the NexusOne is not compiled to work with this kernel that we are using therefore WiFi won’t work. There’s a work around but it requires you to have root privileges on your device. Rooting goes beyond the scope of this tutorial. Have your phone rooted in any way that you want (i.e. by using the SuperOneClick tool (it requires a Windows machine or luck with a Linux one).

First you copy the compiled kernel module to the phone /sdcard

cd ~/android/google-kernel
adb push drivers/net/wireless/bcm4329/bcm4329.ko /sdcard/

Then you need to make the phone /system partition writable, back up the old module and install the new one

adb shell
su
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
cd /system/lib/modules/
cat ./bcm4329.ko > ./bcm4329.ko-orig
cat /sdcard/bcm4329.ko > ./bcm4329.ko
mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system

At this point your WiFi should be working again! :)

On flashing for awesome later use

Now that you tested that your compiled/(modified) kernel is actually working you may want to have it installed also after rebooting the phone. To achieve this you need to flash it to the phone internal storage. It is advisable that first you backup everything using a recovery tool (Amon RA 2.0.0 for the NexusOne works great with the nandbackup tool).

First grab two utilities that will be needed for this step and unzip them into the ~/android/bootimg_builder directory that we have created previously.

Throughout this part of the tutorial I will give commands for both the Magic and the NexusOne, please use only the ones that are useful for your case.

We first need to grab the boot.img file from the running device, have the device running and connected to the PC via USB then issue the command

cd ~/android/bootimg_builder
adb shell
cat /dev/mtd/mtd2 > /sdcard/mtd2.img
exit
adb pull /sdcard/mtd2.img ./nexus-boot.img

OR for the MAGIC

adb pull /sdcard/mtd2.img ./magic-boot.img

We now extract the boot.img-kernel and ramdisk by using the supplied perl script

./split_bootimg.pl nexus-boot.img

OR for the MAGIC

./split_bootimg.pl magic-boot.img

The output of this command will be along the lines of:

Page size: 2048 (0x00000800)
Kernel size: 2226104 (0x0021f7b8)
Ramdisk size: 164628 (0x00028314)
Second size: 0 (0x00000000)
Board name:
Command line: no_console_suspend=1 msmsdcc_sdioirq=1 wire.search_count=5
Writing nexus-boot.img-kernel ... complete.
Writing nexus-boot.img-ramdisk.gz ... complete.

We now need to copy the compiled kernel to our working directory discarding the one extracted previously

cd ~/android/bootimg_builder
cp ../google-kernel/arch/arm/boot/zImage ./nexus-boot.img-kernel
OR for the MAGIC
cp ../cm-kernel/arch/arm/boot/zImage ./magic-boot.img-kernel

Now we combine everything into just one boot.img that we can then flash to the device

./mkbootimg --kernel nexus-boot.img-kernel --ramdisk nexus-boot.img-ramdisk.gz -o boot.img --cmdline 'no_console_suspend=1 msmsdcc_sdioirq=1 wire.search_count=5' --base 0x20000000

OR for the MAGIC

./mkbootimg --kernel magic-boot.img-kernel --ramdisk magic-boot.img-ramdisk.gz -o boot.img --cmdline 'no_console_suspend=1 console=null'

At this point we’re ready to flash the new image to the device, have it in fastboot mode (TRACKBALL on the NexusOne, BACK on the Magick while booting up) and issue the command

fastboot flash boot boot.img
fastboot reboot

If everything has gone well enjoy your new kernel installed definitively on your device. You did make a nandbackup before in case you want to go back, right? Well, I told you to :D

Conclusion and Acknowledgments

Hope you enjoyed this full tutorial on everything needed to compile, test and install a kernel on a NexusOne or on a Magic with CyanogenMod installed. I would like to thank you all that have done the hard work of writing tutorials on how to do so before [here|here], the guys that maintain CyanogenMod [here|here] and those who wrote the perl script to extract the two images from the boot.img file [here]. Mine has been just a work of aggregation. But I wanted to have everything working and described in a single post.

Cheers.

~C

Logitech Wave Pro – MacOSX

Hi all,
short post, but hopefully helpful to some!

I recently bought a new keyboard + mouse set from logitech. I tendo to get quite bad with the wrists, especially when typing much. Long story short, I have been using a Logitech Wave keyboard for a long time! Now, since I will be spending much time at the office (and not only at home) I thought I could buy a new set for office/home. I just went to the Logitech website and set for a wonderful Logitech Wave Pro. Now, if only I had checked the fact that they say that it’s not compatible with MacOS X!

But well, the set arrived, I plugged it in, and to my horror it wasn’t recognized in the System Preferences Logitech Control Center (latest version, 3.3.0). The message was simply: “No Logitech Device Found”…

My “hacker” spirit of course couldn’t bear with this fact. Especially because the keyboard looked exactly like the Wave (not the Pro, mind it)… The mouse itself is simply an MX1100, which is supported by default… Weird, weird.

I started digging and found out the the (in)famous Logitech Software installs some special files in the usual paths:

/Library/Application Support/Logitech.localized/Logitech Control Center.localized/LCCDaemon.app/Contents/Resources

In particular files named:

Hardware Descriptions 2002.plist
Hardware Descriptions 2006.plist
Hardware Descriptions 2007.plist
Hardware Descriptions 2008.plist
Hardware Descriptions 2009.plist
Hardware Descriptions 2010.plist

Now, if one is to open such files with the standard application (Property List Editor) he will find something along the lines of:

Bingo! Now I only had to find out the actual HEX number/product ID. How? Easy, I switched to a windows installation, installed the Logitech SetPoint software, dumped a text file generated by the bug/hardware/problems reporter and voila, found my numbers:

0.000 Device 0x009018d8 parent=0xffffffff model=0x0300001e bus=2-USB       type=3-RECEIVER  ser=	 vid=046D pid=C517 rev=3810 name=Loreley 2RX
0.000 Device 0x008010b0 parent=0x009018d8 model=0x01000087 bus=2-USB       type=1-MOUSE     ser= vid=0000 pid=003C rev=0000 name=LX8 Cordless Laser Mouse (Gomera Dkt)
0.000 Device 0x00a02100 parent=0xffffffff model=0x0300001e bus=2-USB       type=3-RECEIVER  ser=	 vid=046D pid=C517 rev=3810 name=Loreley 2RX
0.000 Device 0x00700888 parent=0x00a02100 model=0x0200005b bus=2-USB       type=2-KEYBOARD  ser= vid=0000 pid=0060 rev=0000 name=Wave Cordless Keyboard
0.000 Device 0x00d03978 parent=0xffffffff model=0x03000030 bus=2-USB       type=3-RECEIVER  ser=	 vid=046D pid=C529 rev=0700 name=eQuad desktop receiver (Kiwi DT Mercury)
0.000 Device 0x00b02928 parent=0x00d03978 model=0x02000063 bus=2-USB       type=2-KEYBOARD  ser=QADR:38CC4662 vid=0000 pid=2003 rev=0000 name=MKT name TBD (Mercury)
0.000 Device 0x00c03150 parent=0x00d03978 model=0x0100008e bus=2-USB       type=1-MOUSE     ser=QADR:38CC4662 vid=0000 pid=1015 rev=0000 name=MX Pro (Macau RC)

I just copied the MX1100 entry in the 2008.plist file and modified the pID (actually just one number increase!) and the one for the wave keyboard. Restarted the Logitech Demo and everything is fully working (well, almost, some keys on the keyboard are apparently mapped in a different way, but I never use them too much, it _might_ be fixable, if I have some more time…).

Anyway, for those who didn’t understand too much, here’s a .zip with the new file, you can just unzip it and place it in your directory, restart the Logitech Daemon (or reboot the PC) and your Wave Pro Set will now be supported!

  1. Download the .zip
  2. Uncompress its content
  3. in the Finder go to: /Library/Application Support/Logitech.localized/Logitech Control Center.localized/
  4. Right-click on the LCCDaemon.app and Show Package Contents
  5. go into Contents/Resources/
  6. (optional) backup the file called: Hardware Descriptions 2008.plist
  7. Copy the uncompressed file
  8. Reboot (or restart the Logitech Daemon from the Activity Monitor/Terminal)

As a result, you will get this beauty in your Logitech System Preferences

Hope it helps!

~Claudio

Sparkle script in XCode

So,
for a project that I’m working on (Reader Notifier Reloaded, more about it in a following post), I’ve been using Sparkle. It is a great tool for providing updates to the users.

Since Sparkle is using public/private key cryptography in order to sign the updates and guarantee their authenticity there is some “fiddling” one has to do in order to push out an update. Marc Liyanage provides us with a great way to do all the signing, packaging and xml generation for updates.

I’ve been using his technique and just adapted the shell script to make it work on my Snow Leopard 10.6.3 without the need of the libxml perl library.

In particular I’ve changed the SIGNATURE part to:

SIGNATURE=$(
	myvar=$(security find-generic-password -g -s "Sparkle Private Key" 2>&1 1>/dev/null | sed 's/.*-----BEGIN DSA PRIVATE KEY-----\\012\(.*\)\\012-----END DSA PRIVATE KEY-----.*/-----BEGIN DSA PRIVATE KEY-----\
\1\
-----END DSA PRIVATE KEY-----/g' | sed 's/\\012/\
/g')

echo "$myvar" > tmp.tmp

openssl dgst -sha1 -binary < "$ARCHIVE_FILENAME" \
| openssl dgst -dss1 -sign tmp.tmp \
| openssl enc -base64

rm tmp.tmp
)

So, here’s the script I’m using, if anyone wants it!

set -o errexit

if [[ $BUILD_STYLE != "Deploy" ]]; then
	echo Distribution target requires "'Deploy'" build style
	exit
fi

VERSION=$(defaults read "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.app/Contents/Info" CFBundleVersion)
DOWNLOAD_BASE_URL="http://www.example.com/some_product"
RELEASENOTES_URL="http://www.example.com/some_product/$VERSION.html"

ARCHIVE_FILENAME="${PRODUCT_NAME}_$VERSION.zip"
DOWNLOAD_URL="$DOWNLOAD_BASE_URL/$ARCHIVE_FILENAME"
KEYCHAIN_PRIVKEY_NAME="Sparkle Private Key"

WD=$PWD
cd "$BUILT_PRODUCTS_DIR"
rm -f "$PRODUCT_NAME"*.zip
ditto -ck --keepParent "$PRODUCT_NAME.app" "$ARCHIVE_FILENAME"

SIZE=$(stat -f %z "$ARCHIVE_FILENAME")
PUBDATE=$(LC_TIME=en_US date +"%a, %d %b %G %T %z")
SIGNATURE=$(
	myvar=$(security find-generic-password -g -s "Sparkle Private Key" 2>&1 1>/dev/null | sed 's/.*-----BEGIN DSA PRIVATE KEY-----\\012\(.*\)\\012-----END DSA PRIVATE KEY-----.*/-----BEGIN DSA PRIVATE KEY-----\
\1\
-----END DSA PRIVATE KEY-----/g' | sed 's/\\012/\
/g')

echo "$myvar" > tmp.tmp

openssl dgst -sha1 -binary < "$ARCHIVE_FILENAME" \
| openssl dgst -dss1 -sign tmp.tmp \
| openssl enc -base64

rm tmp.tmp
)

[ $SIGNATURE ] || { echo Unable to load signing private key with name "'$KEYCHAIN_PRIVKEY_NAME'" from keychain; false; }

cat > $VERSION.xml <<EOF
<item>
	<title>Version $VERSION</title>
	<sparkle:releaseNotesLink>$RELEASENOTES_URL</sparkle:releaseNotesLink>
	<pubDate>$PUBDATE</pubDate>
	<enclosure
		url="$DOWNLOAD_URL"
		sparkle:version="$VERSION"
		type="application/octet-stream"
		length="$SIZE"
		sparkle:dsaSignature="$SIGNATURE"
	/>
</item>
EOF

XCode custom templates

I’ve been developing some iPhone applications both for fun and profit. Always I haven’t liked the way XCode creates new files in a project. Not only I didn’t like the formatting of the top comment (where your name shows and so on) but also I most of the times found myself deleting all the pre-generated contents.

For this reason I’ve investigated a bit in how to create custom templates and, starting from Apple defaults and the work done by jad I put up a simple project that anyone can edit to change to their own preferences and a simple script that links the templates so that XCode can (and will!) show them when you create new files.

I hope someone will find it useful, if no-one does no big problems, I still use it for myself and my collaborators :)

You can find the project and installation instructions (just running the script) on github

~C

ImageMagick for iPhone via SnowLeopard

UPDATE: iOS4.3 and Xcode4

1.5.2010 – UPDATE: for the latest compiled libraries and test project please refer to: Latest ImageMagick

Hi all ImageMagick developers!

It has been a long time since my last update to my script for building ImageMagick and having it running as a statically compiled library so that you can use it in all your iPhone applications! To make up for the delay I have made some improvements:

  • Script now working on Snow Leopard (tested on 10.6.2 against iPhone SDK 3.1.3)
  • Script better organized (although I want to make it even better!)
  • Script available through github, so if you want to help me updating it, know some bash scripting, and willing to help, just contact me!
  • Updated libpng to v1.4.0 and libtiff to v1.9.2

As usual I also link you a .zip containing all the .a universal (iPhone + iPhoneSimulator) libraries that you can use right away in your projects! I’ve also updated the test project, just minor changes, and the new libraries!

I hope you are happy with the update, and I would like to thank:
Verdier Christophe for a much better script stub posted in the comments
Cocoawithlove.com for a good guide on understanding why the heck the iPhoneSimulator libraries weren’t working at all!

Don’t be shy and comment, also pointing me to some cool iPhone Apps that you’ve been working on that use ImageMagick!

~C

ImageMagick on iPhone – update with TIFF

UPDATE: iOS4.3 and Xcode4

PLEASE READ THE UPDATE

Here I go again with an update to the ImageMagick on iPhone saga.

As requested by a few people here on the site, I’ve added TIFF functionality to the compiled library. If you’re interested in reviewing the all process to compile ImageMagick for the iPhone please refer to my two previous posts where that’s described in detail: first and second.
TIFF is compiled with ZIP functionality, so you can compress your TIFF files.

As usual I’ve provided you with an updated script which now enables the compilation of tiff-3.8.2 alongside jpeg and png to have it supported in ImageMagick.

For the lazy there’s always the compiled static libraries and includes. But remember to take as well the *.xml configuration files for some ImageMagick functionality!

And the IM_Test Xcode project has been updated as well where the TIFF functionality is tested.

I guess I’ve updated everything accordingly. Please let me know if anything isn’t working for you. As usual contacting me here on the site.

ciop ciop

ImageMagick on iPhone – Xcode

UPDATE: iOS4.3 and Xcode4

PLEASE READ THE UPDATE

UPDATE! (30.08.09)
Thanks to Jon Kean (see comments) the downloadable project now shows how to use images with unusual number of bits per component. As usual look at the defines at the top to check the functionality you want.

UPDATE! (14.07.09)
Thanks to Karl (see comments) the downloadable project now shows different ways of integrating ImageMagick with Objective-C UIImages offering both compressed methods, using JPEG compression as an example, and raw-data methods. Look at the define at the top to change which method the program will be using.

Many of you have asked me if I could post an Xcode project example to use the libraries and ImageMagick, and so, here it is.

The code is self-describing so I didn’t comment it much, it’s just a few functions call. All it does in this case is loading an image from an UIImage (Objective-C) into a format that ImageMagick (C) understands and can manipulate. Then it applies an ImageMagick filter (OrderedPosterize), which uses a configuration file (thresholds.xml).

Everything is working fine, and you have the complete set of libraries, headers and configuration files, and a configured XCode project right at hand.

All downloadable from here

If you still have any problem, don’t hesitate to contact me!

ciop ciop

ImageMagick on iPhone – UPDATE

UPDATE: iOS4.3 and Xcode4

PLEASE READ THE UPDATE

I’ve been busy working on an iPhone project using ImageMagick the last month, and one thing has kept on bugging me: Some functionality just wasn’t working!!!

In particular I discovered that ImageMagick uses some XML configuration files for some of its internal operations. You can find the whole reading about them on ImageMagick site.

After fiddling, deciding to not care, re-deciding that I WANTED THE FUNCTIONALITY here’s the solution (as usual in steps):

  1. The Files that need to be copied over are stored, if you use my script to compile ImageMagick under the installation directory:
    ~/Desktop/tmp_target/imagemagick/lib/ImageMagick-6.5.3/config
    ~/Desktop/tmp_target/imagemagick/share/ImageMagick-6.5.3/config
  2. XCode needs to import such files, so that they can be copied over to the destination application. In particular add them to the Resources directory with the usual method for adding files:
    Right click on the Resources folder -> Add -> Existing Files…
    and select all the .xml files in the two folders above.
  3. The Code somewhere, like in a function that gets called only once (viewDidLoad, for instance), this may vary depending on your program, add the two following lines:

    NSString * path = [[NSBundle mainBundle] resourcePath];
    setenv("MAGICK_CONFIGURE_PATH", [path UTF8String], 1);
    

Done, now ImageMagick knows where to look for the needed configuration files and will work like a breeze for you.

YES! It was this easy. But not to discover, trust me! :P

ImageMagick on iPhone (with jpeg + png)

UPDATE: iOS4.3 and Xcode4

PLEASE READ THE UPDATE

I’m working on some iPhone applications, which need some image filtering. For now, I won’t say more! Stay tuned for the news when it comes out!

Long story short, I soon found the need (ant the challenge was a good one) to get ImageMagick static libraries so that I can use it on the iPhone. Not only that, but with jpeg and png support. That’s what I need.

After a fast search through the net, I couldn’t find a single _GOOD_ post on how to do that. Just some bits and bytes – Nothing complete.

I soon set on a mission to get ImageMagick to work on the iPhone, as a library. And here’s the result of my quest (around 1 day of search, trials and errors, and at last some light!)

Setting

I’m running MacOSX 10.5.7, with the latest MacPorts installed. If you don’t, get it! I have many ports installed, the ones I “think” are important are:

  • jpeg
  • libpng

Also, I’m testing everything with the latest beta of the iPhoneOS 3.0 – It should be working also for 2.2.1 and the final 3.0 when it comes out.

The Script

I now provide you with a shell script that should do the whole trick of creating the static libraries needed in Xcode for iPhone development.

Just download it, give it run permission (chmod +x ./compile_im.sh), and launch it. It will ask for your password because it needs to copy a file that is not owned by you, the user.

Before complaining that it’s not working, open it, and look at the required directory structure for it to work.
In particular you will need:

  • a Desktop folder named cross_compile
  • ImageMagick source: ImageMagick
  • jpeg source: jpeg
  • – to which I’ve added the MacPorts patches

  • libpng source: libpng
  • Untar ImageMagick source and place it into ~/Desktop/cross_compile/i_m
  • Untar/Unzip jpeg/libpng source and place it into: ~/Desktop/cross_compile/i_m/IMDelegates/jpeg-6b and ~/Desktop/cross_compile/i_m/IMDelegates/libpng-1.2.37

Now you can run the script :)

Result

The result will be stored under: ~/Desktop/tmp_target. In particular you can find all the header files needed while developing your application under: ~/Desktop/tmp_target/im_libs/includes (divided by library). While all the static libraries are inside ~/Desktop/tmp_target/im_libs/:

  • libjpeg.a
  • libpng.a
  • libMagickCore.a
  • libMagickWand.a

Please note that the script joins both the i386 and the arm build inside one single .a static library to ease up developing (for testing both on the Simulator and on the device itself. When finishing up the application you may want to put only the arm library to make the overall application lighter.

XCode configuration

Step 1

To work with your libraries you need to put some easy adjustments to your Project in XCode. I’ve found that the best thing to do, especially in a shared environment with multiple developers, to just put everything inside the XCode project. To do so do:

  • Project->Add To Project->Select all the .a libraries->Click ‘ADD’
  • Project->Add To Project->Select the folders inside the ~/Desktop/tmp_target/im_libs/include->Click ‘ADD’

Step 2

Click on Project->Edit Project Settings and edit (in the Build:

  • Other Linker Flags: -lMagickCore -lMagickWand -lz -lbz2 -ljpeg -lpng
  • Header Search Paths: $(SRCROOT) – make it Recursive
  • Library Search Paths: $(SRCROOT) – make it Recursive
  • On the lower left click on the small-wheel and select: Add User-Defined Setting
    • Key: OTHER_CFLAGS
    • Value: -Dmacinsoth=1

This should be enough to make you start.

For the Lazy

If you’re lazy, don’t manage or for whatever other reason you can just download the whole compiled package

Last note

In case the script doesn’t work, you have questions/suggestions/support please don’t hesitate to contact me, and in case you need help with the script please send me the FULL output in a file.
./compile_im.sh > file_to_send.txt

ROR on Xampp on Win

For those who don’t understand the title don’t worry, this is a “technical” post: installing Ruby on Rails (ROR) over an existing XAMPP (Apache, PHP, MySQL, …) installation in Windows. For all of those who have somehow a Windows “server” used to test websites and want to install Ruby and the fantastic Ruby on Rails framework.

Prerequisites: a working installation of XAMPP, in my example installed under: C:\xampp.

  1. Install ROR via the “one click installer” which can be found on the ROR site: installers list. To have everything in one “web-development directory” when prompted by the installer choose C:\xampp\ruby
  2. Open the dreaded DOS-prompt or cmd: Start->Run->cmd
  3. First off update gem, The version installed will stop whenever an update fails, to solve this update gem first. Let’s navigate to the ruby bin directory:
    cd C:\xampp\ruby\bin
    and then the command:
    gem update --system
  4. Now all the gems are updated, install rails with this command:
    gem install rails --include-dependencies
    This will take a while especially for generating the whole documentation, don’t worry, everything is going all right, wait and be patient
  5. Create a test application with the command:
    rails C:/xampp/htdocs/testapp
    If all went fine you will see some output saying that some files have been created. Rails is installed all fine
  6. Now it’s time to create a Virtual Host in apache to test out our installation. Edit the file: C:xamppapacheconfextrahttpd-vhosts.conf with your favourite good editor. I always have installed Notepad++ and at the end add the following lines:
    ## ROR
    Listen 3000
    <VirtualHost *:3000>
    	ServerName ROR
    	DocumentRoot "C:\xampp\htdocs"
    	<Directory "C:\xampp\htdocs">
    		Options ExecCGI FollowSymLinks
    		AllowOverride all
    		Allow from all
    		Order allow,deny
    		AddHandler cgi-script .cgi
    		AddHandler fastcgi-script .fcgi
    	</Directory>
    </VirtualHost>
    ## END-ROR
    
  7. Restart apache from the XAMPP control panel and then go, on your favorite browser to:
    http://localhost:3000/testapp/public
    To see if everything went fine, the page should look like this screenshot
    ROR installed on XAMPP in Windows

    ROR installed on XAMPP in Windows

Versions

At the moment of this writing this is the list of version numbers for the installed applications running and working as configured in this post:

  • XAMPP: 1.6.6a
  • ruby -v: ruby 1.8.6 <2008-08-11 patchlevel 287> [i386-mswin32]
  • gem -v: 1.3.3
  • rails -v: Rails 2.3.2

I would like to thank the author of this post which is the starting point of my post. I just did some minor changes to remove some errors, especially when updating gems. Also I changed the file to edit to add the Virtual Host to keep things more clean in the http.conf file.

For any trouble don’t hesitate to contact me!

ABOUT

CLOUD GOES SOCIAL is the personal blog of Claudio Marforio.
He holds a MSc in Computer Science with focus on Information Security granted by ETH Zurich. He is currently a PhD Student in the System Security Group of ETH Zurich

Categories

Donate

If you appreciate my work, my applications, this blog in general or you simply feel like rewarding me for something please consider donate.
Any amount will motivate me in keeping up with the blog and the applications.


Thank you!

Donors

F. Olsen, W. Chang, W. Edmondson, C. Sharff, M. Brown, G. Helton, J. de Ruiter, K. Langner, K. Smith, T. OHalloran, B. Zabarauskas

Listening to ...