iPhone iPad SDK 4 OpenFrameworks and FreeImage


I am having a horrible time trying to get OpenFrameworks to work properly with the SDK 4.0.

Here’s the various workflows that I have been doing:

  1. Start from a fresh install of openframeworks (with the FreeImage library included in that download)
  2. Build the code, get a DWARF error during linking
  3. Install the new FreeImage library
  4. Build the code, it works
  5. Make a change to the code, rebuild it
  6. Get the typical “conflicting BOOL definition” error

From there, if I redo steps 1-5, it can work again, however this is too troublesome to do every single time you edit the code.

Has anyone come up with a workaround? Is anyone working on one? When will it be fixed?

Many thanks,


I got both of those errors too, in that order, but after building the FreeImage lib and adding it to my project, neither error has come back despite many code changes and "clean all"s. I assume your just changing your app code, right? Not changing OF lib code?

Hi Gwydion,

Thanks very much for the reply. Can you go into more detail about building the FreeImage library? Is it the steps from this thread: http://forum.openframeworks.cc/t/xcode-3.2.3-±iphone-sdk-4-beta-works-with-ofxiphone/3658/12

Right, not modifying the OF code, just changing my App’s code.

Many thanks if you can give more details about the FreeImage thing. :slight_smile:


Yes, exactly those steps 1-5 that you linked. Followed that to the letter and it worked. I assumed that that process would fix it for everyone on the new SDK, but maybe I was just lucky… :?

Woohoooo! Managed to get it to work!

Here’s the steps that I took…

  1. Cleaned everything. Started off with the default OF FreeImage library (so that you get the DWARF error)

  2. Downloaded the FreeImage source

  3. Edited FreeImage.h …

#define BOOL int32_t (instead of the typedef)

and added:

#undef BOOL (at the bottom before the last #endif)

  1. Make’d it (followed the steps in the post linked to before…)

  2. Deleted the iphone_universal.a in the FreeImage lib

  3. Added the two new .a’s to the FreeImage lib folder

  4. Dragged the two .a’s to Xcode in libs/core libraries/FreeImage/lib/iphone (do not check the checkbox that asks to Copy the files)

  5. Build

  6. Edit something, build again

Works OK!

However, the colour issue is now apparent. It’s the same one as mentioned here: http://forum.openframeworks.cc/t/xcode-3.2.3-±iphone-sdk-4-beta-works-with-ofxiphone/3658/15 Has anyone found a fix for that?

This helps the color issue:

I found that for the channel issue in iPhone SDK 4.0 I had to change in ofImage::loadImageIntoPixels
to get the red and blue channels correctly.


			if (byteCount != 1) swapRgb(pix);  


			if (byteCount != 1) swapRgb(pix);  

also in saveImageIntoPixels

change to:

		if (pix.bytesPerPixel != 1) swapRgb(pix);  
	FIBITMAP * bmp	= getBmpFromPixels(pix);  
		if (pix.bytesPerPixel != 1) swapRgb(pix);  

Well, I don’t want to be too optimist but I got it working now.

I have Xcode 3.2.3 + OF 0061 + iOS4.

What I did is keep the original FreeImage.h and the original libFreeImage_iphone_universal.a.

Then I added to my project the two files of the new version of FreeImage (after downloading and compiling it)

by dragging them into the FreeImage library group.

Then, inside Target > myProject > Link Binary with Libraries I just moved the old one to the bottom (to give linking precedence to the other two files) so that this is the order:

Finally I had to apply the color fix (find it in this thread).

With these passages it seems working fine BOTH on Simulator 3.2 and 4.0 and Device 3.2 and 4.0.