Running ofxopenni

Hey all,

I am new to both xcode and openframeworks, and I am having a bear of a time getting ofxopenni to run. I cannot even get the example to work.

Here’s what I have done:

I have placed all the folders from github into a folder named “ofxOpenNI” in addons, and from that folder I have copied the “example” folder and placed it into the apps folder. However, when I run the example program it does not work. I have noticed that in xcode the file named openFrameworksLib.xcodeproj is red. This seems bad.

Could someone lay out the next steps that I must take in detail fit for an untrained monkey?

And please do not refer me to the following directions. They are absolutely confusing for someone unfamiliar with xcode and frameworks.


  • In XCode, create a new group “ofxOpenNI”
  • Draw these directories from ofxOpenNI into this new group: ofxOpenNI/src
  • Add a search path to: …/…/…/addons/ofxOpenNI/include/
  • Copy the “ofxOpenNI/mac/copy_to_data_path” to your bin/data directory of your application.
  • Drag and drop the file: bin/data/openni/lib/libOpenNI.dylib into your project

There’s a new version of ofxOpenNI up on my repository with revised instructions for getting the examples to work…perhaps they will help.

Thank you. I have made some progress, but I still get a bunch of errors, and I suspect that its because I do not know how to handle the following in the project.xcconfig file:

OF_PATH = …/…/…

#include “…/…/…/libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig”


I have never worked with an IDE before or a framework so could you be more explicit, sort of like if you were talking to a slow 2 year old? I do not understand what the “root of our path relative to this project” means. And also in the “#include” do I just put the full path name? for example: "Users/Jeff/Desktop/Jeff’s kinect project 2/libs…

Thanks again for your help,


Am i glad i stumbled on this…I spent the last two days trying to get any of the ofxOpenNI examples working. Yesterday i brought down gameover’s most recent rep from github (new to github so that took a while). But nothing would work…

Today just looked at this post, used the new instructions posted today from gameover…and shazam!!! It works…although it looks like last nights fall over the 20 foot Kinect cable has maybe shagged my Kinects color camera as the color image is flickering? maybe.

Anyhow i did everything in the instructions (you need to creata the “openni” directory in your "“yourexample/bin/data/” folder ) and then copied the normal OF 62 example added the #include ofxOpenNI.h to testapp.h…checked it all built. Then deleted all the code in testapp.h and testapp.c in my example and replaced it with the code in gameover’s example (the one shipped with his ofxOpenNI) . Then copied the “config” folder from his example into my “yourexample/bin/data/openni” and it all works and was tracking nicely.

Huge thanks to gameover for the updated readme…and for jwtonn for sharing his post.

Hey nikpalmer,

Thank you for your reply to my ofxopenni query. It was helpful, however I am still having problems. When I try to compile the OF 62 example It cannot the file ofxOpenNI.h (no such file or directory, it says).

Here’s what I did:

I followed gameoverhacks instructions and copied his example into “yourofdir/apps/yourworkingdir” folder and then copied and pasted “lib” per his instructions. Next, as you suggested, I copied the OF 62 example and also moved it into yourofdir/apps/yourworkingdir. From there I added the
#include “ofxOpenNI.h” to testApp.h but when I build I get the following error:

/Users/xiouyang/Desktop/Jeffs kinect project/apps/myApps/ofxOpenniExample_from ofx/src/testApp.h:7:0
/Users/xiouyang/Desktop/Jeffs kinect project/apps/myApps/ofxOpenniExample_from ofx/src/testApp.h:7:23:
error: ofxOpenNI.h: No such file or directory

I have a couple questions:

  1. what do you mean by "you need to creata the “openni” directory in your ““yourexample/bin/data/” folder”. Are you simply confirming gameoverhacks instructions or is this an additional step?

  2. if it is an additional step, what and where is the openni directory? Sorry if I am obtuse, but I am so new to all of this (xcode, frameworks, addons and such).

  3. Why am I getting a “No such file or directory” error?

Thank you for any help you can provide,


did you fix your problems??? I have the same problem with OF 007

@jwton and @christophepouly

Ok it’s a bit confusing getting a library with both includes and pre-compiled (in this case dynamic) libraries setup. In order for me to understand what’s happening can you answer some questions?

Can you get the example to compile successfully? Ie., copying my example to your apps/yourworkingdir folder; then copying the libs folder to the apps/yourworkingdir/example/bin/data/openni/ directory…

This is the first place to start…and it’s easiest to just modify that example if you’re struggling with the adding the libraries and includes…

However, if you are trying to make your own project then there is no need to go copying my example to your apps/yourworkingdir

Instead copy a blank empty example to apps/yourworkingdir

Make a folder in bin/data called openni/

* This is important and missing from my instructions on github (sorry!!) you need to copy the config/ directory from my example into the openni/ folder you just made in your own example app.

Then you need to copy the lib folder from ofxOpenNI/mac/copy_to_data_openni_path to your openni/ folder

IE., you should now have two folders in bin/data/openni, one called config the other called lib

Ok, but we’re not done. In order for the compiler to know where all the files are we need to drag a number of items into Xcode (as per the github instructions):

In Xcode make a new Group called ‘ofxOpenNI’ under ‘Addons’ (right or control click the ‘Addons’ Group, select Add->New Group)

Drag the ‘src’ and ‘include’ folders from inside the ofxOpenNI folder (in your addons directory) into the Group ‘ofxOpenNI’ you just made.

Drag the folder ‘lib’ from bin/data/openni (the one you just copied) into the Group ‘ofxOpenNI’

So inside Xcode it should look like my example in your addons:


I hope that helps…


@gameover :

Hey man. been checkin out your ofxOpenNI fork- I just noticed it after I had spent a lot of work already on roxlu’s, getting threaded .oni loading working, drawing using glDrawArrays, caching X/Y world positions to multiply by z depth, etc.
I am more or less trying to merge the best of my additions + yours. Good stuff in yours! I love the libfreenect tilt addition.

But- I am curious about your method in making the portable dylibs. I am using the latest installation of openNI/avin2’s sensorkinect with a custom built bayer.cpp so that it doesn’t look interlaced/NITE - so I’m trying to reform/repackage them so they load properly.

Usually i would create a run script phase that does something like this:

#copy the dylib into the bundle
cp -f …/…/…/addons/ofxOpenNI/mac/openni/libnimCodecs.dylib “$TARGET_BUILD_DIR/$”;

#fix reference to libOpenNI inside libnimCodecs
install_name_tool -change …/…/Bin/Release/libOpenNI.dylib @loader_path/…/MacOS/libOpenNI.dylib “$TARGET_BUILD_DIR/$”

#fix install name of libnimCodecs
install_name_tool -change “…/…/Bin/Release/libnimCodecs.dylib” @loader_path/…/MacOS/libnimCodecs.dylib “$TARGET_BUILD_DIR/$$PRODUCT_NAME”

#rinse/repeat previous steps for all related files, based on otool -L x.dylib, or by seeing what causes a runtime crash

Is this essentially what you did to the dylibs, or is there an additional step for making the app portable?

Hi there.
You can try my fork of ofxOpenNI, in which I added an automatic skeleton recognition capability.
-download it
-copy the dowloaded folder to OF’s addons folder
-Copy the floder in folder mac to AutoSkeletonExample/bin/data
-Install the latest unstable version of OpenNI, NITE and avin2’s kinect driver.

Dont move AutoSkeletonExample folder from where it is.

Once done just open AutoSkeletonExample project and compile.

good luck


It took me ages to figure out how Roxlu got this to work in the beginning…not entirely sure his and my methods are exactly the same, but they seem close enough…

On a mac what I do to get portable dylibs is (generically):

* Find the bit of code in the openNI sources (was XnModuleLoader.cpp but is now in XnOpenNI.cpp) that deals with environment variables and/or hard paths to finding the file “modules.xml” (this file gets read on init’ing openNI and is used to load OpenNI, NITE and SensorKinect dylibs)…you can see what I do to that file here: … basically I just make OpenNI go looking in the openni/config folder…
* Compile the OpenNI dylibs with this modification as per their normal instructions; copy them to a staging folder
* Copy NITE and SensorKinect dylibs to the same folder;
* Use install name tool to change the install paths of all dylibs to reflect their new home within the oF structure…I use the batch file in the libs folder included with ofxOpenNI (Roxlu had one of these, but I needed to modify it a bit to get it to work for me)…see:
* EDIT: and modify the modules.xml file to reflect the correct paths/names of the dylibs I want to load…

Hope that helps!

Would love to see the changes you are talking about to both ofxOpenNI and to the SensorKinect drivers…

i’m on linux and i don’t use codeblocks, i use manually makefiles. i tried to read the readme but i did not understand what to do. can you point me some advice? thanks!

ok i’ve done something really stupid like:

of_path/addons/ofxOpenNI/src$ cp …/include/openni/* . -R
of_path/addons/ofxOpenNI/src$ cp …/include/libusb/* . -R
of_path/addons/ofxOpenNI/src$ cp …/include/nite/* . -R

and it compiles till… this error:

…/…/…/addons/ofxOpenCv/libs/opencv/lib/linux/libopencv_objdetect.a(haar.o): In function cvHaarDetectObjects': haar.cpp:(.text.cvHaarDetectObjects+0x1bf2): undefined reference tocvCanny’


your problem has to do with OpenCV and not OpenNI.
ofxOpenNI doesn’t depend on OpenCV, so it must be something that you added.
are you doing some sort of face detection?

thanks for answer.
of course not. i’m only try to compile ofxopenni example. and i can compile and run correctly ofxopencv example.

ok, in the example in ofxOpenNI include to ofxopencv.h is missing in testApp.h!!

now i have this compiling error:

…/…/…/addons/ofxOpenNI/src/XnStatus.h:50: error: two or more data types in declaration of ‘parameter’
…/…/…/addons/ofxOpenNI/src/XnStatus.h:59: error: two or more data types in declaration of ‘parameter’
…/…/…/addons/ofxOpenNI/src/XnStatus.h:68: error: two or more data types in declaration of ‘parameter’
…/…/…/addons/ofxOpenNI/src/XnStatus.h:68: error: expected ‘)’ before ‘,’ token
…/…/…/addons/ofxOpenNI/src/XnStatus.h:68: error: expected unqualified-id before ‘const’

Of course because ofxopenNI doesn’t need Opencv.
Which version/fork of ofxOpenNI are you trying to run?
Do you have the latest OpenNI and NITE libs installed?

i’ve found a post with openni under linux,
i’m moving there


I have been trying to get the ofxOpenNI samples from gemeover to run on linux (ubuntu 11.04) with openFrameworks 7 and failed so far.

I followed the instructions provided by gameover on and also did this “This is important and missing from my instructions on github (sorry!!) you need to copy the config/ directory from my example into the openni/ folder you just made in your own example app.”

My make file looks like this:

# add custom variables to this file  
# OF_ROOT allows to move projects outside apps/* just set this variable to the  
# absoulte path to the OF root folder  
OF_ROOT = ../../..  
# USER_CFLAGS allows to pass custom flags to the compiler  
# for example search paths like:  
# USER_CFLAGS = -I src/objects  
# -I ../../../addons/ofxOpenNI/src -I ../../../addons/ofxOpenNI/include/openni -I ../../../addons/ofxOpenNI/include/nite  
USER_CFLAGS =  -I ../../../addons/ofxOpenNI/src -I ../../../addons/ofxOpenNI/include/openni -I ../../../addons/ofxOpenNI/include/nite  
# USER_LDFLAGS allows to pass custom flags to the linker  
# for example libraries like:  
# USER_LD_FLAGS = libs/libawesomelib.a  
# use this to add system libraries for example:  
# USER_LIBS = -lpango  
USER_LIBS = -lOpenNI  
# change this to add different compiler optimizations to your project  
USER_COMPILER_OPTIMIZATION = -march=native -mtune=native -Os  

I get the following errors:

/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:33: undefined reference to `ofxOpenNIContext::setup()'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:35: undefined reference to `ofxDepthGenerator::setup(ofxOpenNIContext*)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:36: undefined reference to `ofxImageGenerator::setup(ofxOpenNIContext*)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:38: undefined reference to `ofxUserGenerator::setup(ofxOpenNIContext*)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:39: undefined reference to `ofxUserGenerator::setSmoothing(float)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:40: undefined reference to `ofxUserGenerator::setUseMaskPixels(bool)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:41: undefined reference to `ofxUserGenerator::setUseCloudPoints(bool)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:42: undefined reference to `ofxUserGenerator::setMaxNumberOfUsers(int)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:44: undefined reference to `ofxHandGenerator::setup(ofxOpenNIContext*, int)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:45: undefined reference to `ofxHandGenerator::setSmoothing(float)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:46: undefined reference to `ofxHandGenerator::setFilterFactors(float)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:48: undefined reference to `ofxOpenNIContext::toggleRegisterViewport()'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:49: undefined reference to `ofxOpenNIContext::toggleMirror()'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:51: undefined reference to `ofxOpenNIRecorder::setup(ofxOpenNIContext*, int, int, bool, bool, bool)'  

The list goes on unfortunately. Does anybody know what I am doing wrong?

i had the same problem more or less.
i resolved in this way:

  • make sure you have installed the last openni version.
    you could verify it if you have .so files in /use/lib.

ls /usr/lib/libXn*

this is my output:


and some Xn*.h in /usr/include/ni

  • not copy ofxOpenNI source in of_path/addons but inside of_path/addons/apps/myapps/my_openni_project
    use this config.make:

USER_CFLAGS = -I src/ofxOpenNI/src -I src/ofxOpenNI/include -I /usr/include/ni

USER_LDFLAGS = /usr/lib/ /usr/lib/ /usr/lib/ /usr/lib/ /usr/lib/ /usr/lib/ /usr/lib/ /usr/lib/ /usr/lib/ /usr/lib/ /usr/lib/ /usr/lib/ /usr/lib/ /usr/lib/ /usr/lib/ /usr/lib/


i don’t think this is the best way to do it. but in this way it works, in my case.

ps. i have grabbed the configs here:

hope it helps, let me know!

Hi nkint,

thank you for your reply!

wow that make adjustment got rid of a lot of problems! Thanks a bunch! It is working now!

What I also noticed is that I had a backup main in my src folder, which messed things up even more I think.

Hi guys I’m new to open frameworks and kinect. I’ve followed all the steps up to this point but the addon files within codeblocks are still broken and I can’t call the .h files

hey oceanmachine89,
code`blocks is a bit of a pain IMHO. You need to manually add the paths to the .h files of the addon.
I really don’t remember the exact process to add the includes in CB. google it.