compiling an openNI example in linux (with code:blocks)

Hi all,
I’m new to OF and I’m trying to setup up a working basis.
System is Ubuntu 13.04 64bit.
I have installed OF, and successfully run the “kinectExample” which incorporates ofxKinect and ofxOpenCV core-addons.
Moving on, I try to get ofxOpenNI working, but I fail during build with code:blocks.

A little detail history. I followed instructions from ofxOpenNI github [-https://github.com/gameoverhack/ofxOpenNI](https://github.com/gameoverhack/ofxOpenNI) page, section “DRIVERS & GETTING THE EXAMPLES TO WORK”

I already have OpenNI and NITE libraries (latest v1.x) as well as SensorKinect driver, which I have tested with processing and I get image from Kinect.
I copied the ofxOpenNI examples folder to myapps folder as :

cp -r /addons/ofxOpenNI/examples/opeNI-SimpleExamples /apps/myApps/

Then I moved one of the src-**** folders to src and tried to build the example.
I error I get is the following

In file included from …/…/…/libs/openFrameworks/ofMain.h:53:0,
from /home/nass/dev/of_v0.8.0_linux64_release/apps/myApps/opeNI-SimpleExamples/src/testApp.h:5,
from /home/nass/dev/of_v0.8.0_linux64_release/apps/myApps/opeNI-SimpleExamples/src/main.cpp:2:
…/…/…/libs/openFrameworks/graphics/ofCairoRenderer.h:4:28: fatal error: cairo-features.h: No such file or directory
compilation terminated.
Process terminated with status 1 (0 minutes, 1 seconds)
1 errors, 27 warnings (0 minutes, 1 seconds)

I tried including the “/usr/include” & “/usr/lib” folders in codeblock from

Settings (menu) -> Compiler… -> Global compiler settings -> search directories (tab) -> compiler (the include directive) and linker (the lib directive)

to no avail.

What am I doing wrong?

Thank you for your help

can you post the whole output? that message usually means that a library is not installed in the system. also in linux the configuration of serch paths… is done through the config.make file not in the codeblocks config

hi there,
the full message from debug log tab is the following:

-------------- Build: Debug in openNISample007 (compiler: GNU GCC Compiler)---------------

WARNING: Can’t read file’s timestamp: /home/nass/dev/of_v0.8.0_linux64_release/addons/ofxOpenNI/src/ofxDepthGenerator.cpp
WARNING: Can’t read file’s timestamp: /home/nass/dev/of_v0.8.0_linux64_release/addons/ofxOpenNI/src/ofxGestureGenerator.cpp
WARNING: Can’t read file’s timestamp: /home/nass/dev/of_v0.8.0_linux64_release/addons/ofxOpenNI/src/ofxHandGenerator.cpp
WARNING: Can’t read file’s timestamp: /home/nass/dev/of_v0.8.0_linux64_release/addons/ofxOpenNI/src/ofxHardwareDriver.cpp
WARNING: Can’t read file’s timestamp: /home/nass/dev/of_v0.8.0_linux64_release/addons/ofxOpenNI/src/ofxImageGenerator.cpp
WARNING: Can’t read file’s timestamp: /home/nass/dev/of_v0.8.0_linux64_release/addons/ofxOpenNI/src/ofxIRGenerator.cpp
WARNING: Can’t read file’s timestamp: /home/nass/dev/of_v0.8.0_linux64_release/addons/ofxOpenNI/src/ofxOpenNIContext.cpp
WARNING: Can’t read file’s timestamp: /home/nass/dev/of_v0.8.0_linux64_release/addons/ofxOpenNI/src/ofxOpenNIRecorder.cpp
WARNING: Can’t read file’s timestamp: /home/nass/dev/of_v0.8.0_linux64_release/addons/ofxOpenNI/src/ofxTrackedHand.cpp
WARNING: Can’t read file’s timestamp: /home/nass/dev/of_v0.8.0_linux64_release/addons/ofxOpenNI/src/ofxTrackedUser.cpp
WARNING: Can’t read file’s timestamp: /home/nass/dev/of_v0.8.0_linux64_release/addons/ofxOpenNI/src/ofxUserGenerator.cpp
g++ -Wall -fexceptions -g -MMD -I…/…/…/addons/ -I…/…/…/libs/openFrameworks/ -I…/…/…/libs/openFrameworks/3d -I…/…/…/libs/openFrameworks/events -I…/…/…/libs/openFrameworks/app -I…/…/…/libs/openFrameworks/communication -I…/…/…/libs/openFrameworks/gl -I…/…/…/libs/openFrameworks/graphics -I…/…/…/libs/openFrameworks/math -I…/…/…/libs/openFrameworks/video -I…/…/…/libs/openFrameworks/utils -I…/…/…/libs/openFrameworks/types -I…/…/…/libs/openFrameworks/sound -I…/…/…/libs/rtAudio/include -I…/…/…/libs/fmodex/include -I…/…/…/libs/tess2/include -I…/…/…/libs/kiss/include -I…/…/…/libs/FreeImage/include -I…/…/…/libs/freetype/include -I…/…/…/libs/freetype/include/freetype2 -I…/…/…/libs/gstappsink/include -I…/…/…/addons -I…/…/…/libs/poco/include -I…/…/…/addons/ofxOpenNI/include/openni -I…/…/…/addons/ofxOpenNI/include/nite -I…/…/…/addons/ofxOpenNI/src -I/usr/include/ -c /home/nass/dev/of_v0.8.0_linux64_release/examples/addons/opeNI-SimpleExamples/src/main.cpp -o obj/Debug/examples/addons/opeNI-SimpleExamples/src/main.o
In file included from …/…/…/addons/ofxOpenNI/src/ofxOpenNIUtils.h:37:0,
from …/…/…/addons/ofxOpenNI/src/ofxOpenNITypes.h:32,
from …/…/…/addons/ofxOpenNI/src/ofxOpenNI.h:42,
from /home/nass/dev/of_v0.8.0_linux64_release/examples/addons/opeNI-SimpleExamples/src/testApp.h:4,
from /home/nass/dev/of_v0.8.0_linux64_release/examples/addons/opeNI-SimpleExamples/src/main.cpp:2:
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:4314:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:4315:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:4317:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:4335:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:4336:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:4338:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:4636:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:4637:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:4639:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:4657:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:4658:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:4660:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:5500:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:5501:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:5503:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:5528:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:5529:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:5531:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:5558:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:5559:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:5561:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:5594:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:5595:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:5597:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:5687:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:5688:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
…/…/…/addons/ofxOpenNI/include/openni/XnCppWrapper.h:5690:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
In file included from …/…/…/libs/openFrameworks/ofMain.h:53:0,
from /home/nass/dev/of_v0.8.0_linux64_release/examples/addons/opeNI-SimpleExamples/src/testApp.h:5,
from /home/nass/dev/of_v0.8.0_linux64_release/examples/addons/opeNI-SimpleExamples/src/main.cpp:2:
…/…/…/libs/openFrameworks/graphics/ofCairoRenderer.h:4:28: fatal error: cairo-features.h: No such file or directory
compilation terminated.
Process terminated with status 1 (0 minutes, 1 seconds)
1 errors, 27 warnings (0 minutes, 1 seconds)

I shall try appending /usr/include in the config.make as well.

Thank you

/usr/include is included by default so there’s no need to do that. it seems like no library is being included but for some reason there’s no error message of which could be missing. can you try to compile from a console? just go to the directory of the project and type:

make

then post the output here again

That is odd, I get a different problem from command line.

nass@z61m:~/dev/examples/addons/opeNI-SimpleExamples$ make
compiling object for: src/testApp.cpp
mkdir -p obj/Release/src
g++ -c -march=native -mtune=native -O3 -Wall -fexceptions -I. -I…/…/…/libs/FreeImage/include -I…/…/…/libs/assimp/include -I…/…/…/libs/assimp/include/Compiler -I…/…/…/libs/fmodex/include -I…/…/…/libs/freetype/include -I…/…/…/libs/freetype/include/freetype2 -I…/…/…/libs/freetype/include/freetype2/freetype -I…/…/…/libs/freetype/include/freetype2/freetype/internal -I…/…/…/libs/freetype/include/freetype2/freetype/internal/services -I…/…/…/libs/freetype/include/freetype2/freetype/config -I…/…/…/libs/glew/include -I…/…/…/libs/glew/include/GL -I…/…/…/libs/glfw/include -I…/…/…/libs/glfw/include/GLFW -I…/…/…/libs/kiss/include -I…/…/…/libs/openssl/include -I…/…/…/libs/openssl/include/openssl -I…/…/…/libs/poco/include -I…/…/…/libs/poco/include/Poco -I…/…/…/libs/poco/include/Poco/DOM -I…/…/…/libs/poco/include/Poco/Crypto -I…/…/…/libs/poco/include/Poco/Net -I…/…/…/libs/poco/include/Poco/Zip -I…/…/…/libs/poco/include/Poco/SAX -I…/…/…/libs/poco/include/Poco/Dynamic -I…/…/…/libs/poco/include/Poco/Data -I…/…/…/libs/poco/include/Poco/XML -I…/…/…/libs/poco/include/Poco/Util -I…/…/…/libs/poco/include/CppUnit -I…/…/…/libs/portaudio/include -I…/…/…/libs/rtAudio/include -I…/…/…/libs/tess2/include -I…/…/…/libs/openFrameworks/ -I…/…/…/libs/openFrameworks/events -I…/…/…/libs/openFrameworks/.settings -I…/…/…/libs/openFrameworks/utils -I…/…/…/libs/openFrameworks/video -I…/…/…/libs/openFrameworks/graphics -I…/…/…/libs/openFrameworks/3d -I…/…/…/libs/openFrameworks/gl -I…/…/…/libs/openFrameworks/communication -I…/…/…/libs/openFrameworks/sound -I…/…/…/libs/openFrameworks/app -I…/…/…/libs/openFrameworks/math -I…/…/…/libs/openFrameworks/types pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 libudev --cflags -I/usr/include -MMD -MP -MFobj/Release/src/testApp.d -MTobj/Release/src/testApp.d -oobj/Release/src/testApp.o -c src/testApp.cpp
Package gstreamer-0.10 was not found in the pkg-config search path.
Perhaps you should add the directory containing gstreamer-0.10.pc' to the PKG\_CONFIG\_PATH environment variable No package 'gstreamer-0.10' found Package gstreamer-video-0.10 was not found in the pkg-config search path. Perhaps you should add the directory containinggstreamer-video-0.10.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘gstreamer-video-0.10’ found
Package gstreamer-base-0.10 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gstreamer-base-0.10.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘gstreamer-base-0.10’ found
In file included from src/testApp.cpp:1:0:
src/testApp.h:4:23: fatal error: ofxOpenNI.h: No such file or directory
compilation terminated.
make: *** [obj/Release/src/testApp.o] Error 1
nass@z61m:~/dev/examples/addons/opeNI-SimpleExamples$

I verified I have gstreamer installed, by reinstalling everything:
sudo add-apt-repository ppa:gstreamer-developers/ppa
sudo apt-get update
sudo apt-get install gstreamer1.0*

Then as per suggested by make, I tried to locate the “*.pc” files but I can’t find any.
did “updatedb”, then “locate gstreamer-base-0.10.pc”.

The problem with gstreamer persists.

As for the missing “ofxOpenNI.h” file, I look for config.make in the root example folder (/examples/addons/opeNI-SimpleExamples/). There is none to be found, but makefile itself seems to have $USER_CFLAGS variable exactly for that scope.

In turn I had to add the following for the compilation to succeed:

USER_CFLAGS = \
-I…/…/…/addons/ofxOpenNI/src/ \
-I…/…/…/addons/ofxOpenNI/include/openni/ \
-I/usr/include/cairo/ \
-I/usr/include/gstreamer-1.0/ \
-I/usr/include/glib-2.0/ \
-I/usr/lib/x86_64-linux-gnu/glib-2.0/include/

the “cairo” statement is used to overcome the problem with the “cairo-features.h” that I could see in codeblocks too, but apparently there are more things needed. I wonder how code:blocks building knew about the 2 first ones.

Also I start wondering If I really need to include all these headers by hand, or I am taking a wring path here…

In any case, with these additions the compilation completed (albeit with many warnings).
I get many linker errors for “multiple definition”, so I moved the “src-*” folders out of the examples folder.
This leaves me with only one “undefined reference” problem:

linking bin/opeNI-SimpleExamples
g++ -o bin/opeNI-SimpleExamples obj/Release/src/testApp.o obj/Release/src/main.o -L…/…/…/libs/fmodex/lib/linux64 -L…/…/…/libs/glfw/lib/linux64 -L…/…/…/libs/kiss/lib/linux64 -L…/…/…/libs/openFrameworksCompiled/lib/linux64 -L…/…/…/libs/poco/lib/linux64 -L…/…/…/libs/rtAudio/lib/linux64 -L…/…/…/libs/tess2/lib/linux64 -Wl,-rpath=./libs -lopenFrameworks -lfmodex -lglfw3 -lkiss -lPocoCrypto -lPocoData -lPocoDataMySQL -lPocoDataODBC -lPocoDataSQLite -lPocoFoundation -lPocoNet -lPocoNetSSL -lPocoUtil -lPocoXML -lPocoZip -lRtAudio -ltess2 pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 libudev --libs -lglut -lGL -lGLU -lasound -L/usr/lib/x86_64-linux-gnu/
Package gstreamer-0.10 was not found in the pkg-config search path.
Perhaps you should add the directory containing gstreamer-0.10.pc' to the PKG\_CONFIG\_PATH environment variable No package 'gstreamer-0.10' found Package gstreamer-video-0.10 was not found in the pkg-config search path. Perhaps you should add the directory containinggstreamer-video-0.10.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘gstreamer-video-0.10’ found
Package gstreamer-base-0.10 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gstreamer-base-0.10.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘gstreamer-base-0.10’ found
/usr/bin/ld: …/…/…/libs/glfw/lib/linux64/libglfw3.a(x11_window.c.o): undefined reference to symbol ‘XConvertSelection’
/usr/bin/ld: note: ‘XConvertSelection’ is defined in DSO /usr/lib/x86_64-linux-gnu/libX11.so.6 so try adding it to the linker command line
/usr/lib/x86_64-linux-gnu/libX11.so.6: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make: *** [bin/opeNI-SimpleExamples] Error 1

I tried adding the following in the designated variables in the make file again

USER_LDFLAGS = -lX11
#USER_LDFLAGS = -l:libX11.so.6
USER_LIBS = -L/usr/lib/x86_64-linux-gnu/

but the error persists . Note that I tried to include the libX11.so with the 2 different $USER_LDFLAGS variables (one at a time), but they both failed. Am I linking something the wrong way?

did you run the install_dependencies script? that should have installed all the needed dependencies, there’s no need to install anything manually or add flatgs in the config.make usually

I did, I followed this guide http://www.openframeworks.cc/setup/linux-codeblocks/
and I just double-checked my history. The command is there.

it could be that the makefiles in the openni examples are not up to date, try changing Makefile and config.make from one of the examples in the current release

right!
after a short brake to do other things , I am dealing with ofxOpenNI again !
so I tried creating an empty project with projectgenerator, where I included ofxOpenNI .
the empty project is located in /appz/myappz/openni-example/ .

I then copied one of the src-* folders from openni to that folder and built the project.

I get lots of undefined references during linker stage. The references point to xn* variables

any clue as to how to go about it?

thank you ofr your help