Monday, December 7, 2009

Getting started with openFrameworks on OS X

Openframeworks is a wonderfull API for creative computing. At the beginning it can be hard to start developping with OF because there is no standard way to build the framework.

I made a work on openframeworks build system by adding cmake build capability. The result can produce a standard OSX frameworks and results in an easy to settup build.

The first thing to do is installing the openFrameoworks dependencies.

Installing dependencies

Setup openframeworks install prefix.

sudo mkdir -p /usr/local/include
sudo mkdir -p /opt/local/lib 

RtAudio

RtAudio is a cross-platform API to deal with sound. Download rtAudio at http://www.music.mcgill.ca/~gary/rtaudio/release/rtaudio-4.0.6.tar.gz

Compie RtAudio:
 
./configure
make CFLAGS=-m32
sudo cp librtaudio.a /usr/local/lib
sudo cp RtAudio.h  RtError.h /usr/local/include

Poco

Download poco at http://pocoproject.org/download/

Compile POCO:
edit ./build/config/Darwin and add the -m32 CXXFLAGS

--------------------------------------
CXXFLAGS = -Wall -Wno-sign-compare -m32
--------------------------------------

Then compile Poco:

./configure --no-tests --no-samples Darwin
export POCO_BASE=$PWD

for i in CppUnit Foundation XML Net Util; do
    (cd $i ; make static_release)
done 
 
 
Install poco:

for i in Foundation XML Net Util; do
    sudo cp -rf $i/include/* /usr/local/include/
done
sudo cp lib/Darwin/i386/lib*.a /usr/local/lib

FreeImage

Download FreeImage from http://freeimage.sourceforge.net/download.html

cd FreeImage

# edit Makefile.osx to change paths to SDK. For example on my 10.6 (snow leopard):
-------------------------------------
INCLUDE_PPC = -isysroot /Developer/SDKs/MacOSX10.6.sdk
INCLUDE_I386 = -isysroot /Developer/SDKs/MacOSX10.6.sdk 
--------------------------------------
make 

sudo cp Source/FreeImage.h /usr/local/include/
sudo cp libfreeimage.a /usr/local/lib/libFreeImage.a

Fmodex

Download Fmodex from http://www.fmod.org/index.php/download

Install the package.

After installing package should be installed in /Developer/FMOD Programmers API Mac
Copy the libraries and includes files to /opt/of

cd /Developer/FMOD\ Programmers\ API\ Mac/
sudo cp api/inc/* /usr/local/include
sudo cp api/lib/* /usr/local/lib

GLee

Download GLee from http://www.opengl.org/sdk/libs/GLee/

mkdir GLee
cd GLee
tar zxvf ../GLee-5.4.0-src.tar.gz
./configure CXXFLAGS="-m32 -framework CoreFoundation -framework OpenGL"
make
sudo cp GLee.h /usr/local/include
sudo cp libGLee.so /usr/local/lib 

Building openFrameworks

Download openframeworks from my unofficial github repository. The repository includes CMake files and a patch for openframeworks to be compatible with the lastest RtAudio API.

git clone git://github.com/dopuskh3/openFrameworks.git
cd openFrameworks
cmake -DCMAKE_CXX_FLAGS=-m32 -DCMAKE_INSTALL_PREFIX=/usr/local
make
sudo make install 

Starting a sample project

Now we can start a new project in xcode...

 



 
Drag the sample file into the project to add source code sample. Take theses source code file from openframeworks example advancedGraphicExample:
 

Add a new build target:
 





Setup include paths:
  Add openFrameworks.frameworks and OpenGL.framework to your project:
 
 




Drag the project source code into the target:


Click "build and run":  
 
 

 

1 comment:

  1. Heya! Thanks for your post. Any chance you've run into the following problem?


    CMake Error at /Users/onassar/Temp/openFrameworks/cmake/OpenFrameworks.cmake:198 (message):
    Cannot find quicktime library
    Call Stack (most recent call first):
    CMakeLists.txt:8 (include)


    -- Configuring incomplete, errors occurred!

    I tried installing libquicktime via macports, but no dice :(
    Any help would be appreciated :)

    ReplyDelete