ofxOpenNI : XnOpenNI.h: No such file or directory

I have this error when I try to compile my of app with ofxOpenNI addon:

../../../addons/ofxOpenNI/src/ofxOpenNIUtils.h:35:22: fatal error: XnOpenNI.h: No such file or directory

However the file XnOpenNI.h is present here:


What can I do for the compiler to find it?

1 Like

Problem solved, I just added this to the cflags in my makefile:


I might be having the same problem.
I’m using oF-0.8.0.
If you don’t mind, could you please tell me how you exactly solve this?

I if remember correctly, my installation of OpenNi and NiTE was bad. I reinstalled them and it worked. Follow the instructions from the GitHub page of ofxOpenNI

Hi, I have a similar problem.
The error is ofxOpenNIUTils.h
Lexical or preprocessor issue XnOpenNI.h file not found.

Is the same Elaye?
I found the makefile but I don’t know how to change the route.

The route of my makefile is: # call the project makefile!
include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk


First find the location of your XnOpenNI.h file, and then add the path to your config.make file in the cflags.

For example, if XnOpenNI.h is in /usr/include/ni :

PROJECT_CFLAGS = -I/usr/include/ni 

Adding the

PROJECT_CFLAGS = -I/usr/include/ni

after checking where the file is:

locate XnOpenNI.h

solved the problem. Thank you!

Hello, I’m a beginner of OF and also having this same issue. I’m having trouble resolving it the way described above.

For me, all the header files that are referenced in ofxopenNIutils.h, but cannot be found, are located at this path: /Users/katiesmillie/Dropbox_Katie/sfpc/openFrameworks/addons/ofxOpenNI/include/openni

I tried adding that to my config.make file as described above, but still got the same error. A few questions come to mind:

  1. Should these header files be located in a different place outside of my OF addons folder? It sounds like others above have it in the /usr/include?
  2. Do I need to include “-I” at the beginning of the path name? What does that mean?

Any help would be appreciated. Thank you.

Hi @katiesmillie,
You don’t have to move your header files. But you need to tell the compiler where he can finds them. That’s why this line is for:

PROJECT_CFLAGS = -I/usr/include/ni

So in your case it would be

PROJECT_CFLAGS = -I/Users/katiesmillie/Dropbox_Katie/sfpc/openFrameworks/addons/ofxOpenNI/include/openni

The -I is an option for the compiler to tell him where he can finds headers files. The path /usr/include is a standard path where headers are located on Linux. It seems that your are using a Mac though, so this may not be the right solution for you. This answer may help you.

Elaye, Thank you so much for the reply!

Yes I am using a Mac, and I found the link you provided to be just what I was seeking.

In XCode under Build Settings there is a section for Header Search Paths. I added the missing paths there and my project was finally able to find them. Hooray!

Good point, I always prefer to add Header Paths instead of the config file. It’s more the xcode way.