If you are using Ubuntu x64 or x86 machine, go download one of two files based on your system arch: X64,X86. Unzip it, then

cd OpenNI-Bin-Dev-Linux-x64-v1.5.7.10/
sudo ./install.sh

Then, in order to make OpenNI work with Kinect V1, another patch called SensorKinect is needed. Download according to your system arch, unzip and then:

cd ./Sensor-Bin-Linux-x64-v5.1.2.1
sudo ./install.sh

If you compile your program with -std=c++11 option, and get the following error

/usr/include/ni/XnPlatform.h:73:3: error: #error OpenNI Platform Abstraction Layer - Unsupported Platform!
  #error OpenNI Platform Abstraction Layer - Unsupported Platform!

Edit file /usr/include/ni/XnPlatform.h. Change line 64 to 66 from

#elif (linux && (i386 || __x86_64__))
  	#include "Linux-x86/XnPlatformLinux-x86.h"
#elif (linux && __arm__)

to

#elif (__linux__ && (__i386__ || __x86_64__))
  	#include "Linux-x86/XnPlatformLinux-x86.h"
 #elif (__linux__ && __arm__)