0

I have to use a kinect2 (ubuntu 16.04 LTS). So I installed several things :

When I was using the first kinect I was able to import the libfreenect tools without an problem, but now way with libfreenect !

You can find my CMake here. There isn't any problem with the others libs in the CMake.

What I changed to install libfreenect2:

  • I clone the repository in my folder ~/sofware. (I put all my libs here)

  • Instead of

    cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2
    

    I did

    cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/software/libfreenect2/freenect2
    

With my Cmake when I compile I got this:

CMakeFiles/Kinect2CaptureYM.dir/app/Kinect2CaptureYM.cpp.o: In function `Kinect2CaptureYM::Kinect2CaptureYM()':
Kinect2CaptureYM.cpp:(.text._ZN16Kinect2CaptureYMC1Ev[_ZN16Kinect2CaptureYMC1Ev]+0x108): undefined reference to `libfreenect2::Freenect2::Freenect2(void*)'
Kinect2CaptureYM.cpp:(.text._ZN16Kinect2CaptureYMC1Ev[_ZN16Kinect2CaptureYMC1Ev]+0x427): undefined reference to `libfreenect2::Freenect2::~Freenect2()'
CMakeFiles/Kinect2CaptureYM.dir/app/Kinect2CaptureYM.cpp.o: In function `Kinect2CaptureYM::~Kinect2CaptureYM()':
Kinect2CaptureYM.cpp:(.text._ZN16Kinect2CaptureYMD1Ev[_ZN16Kinect2CaptureYMD1Ev]+0xb8): undefined reference to `libfreenect2::Freenect2::~Freenect2()'
collect2: error: ld returned 1 exit status
CMakeFiles/Kinect2CaptureYM.dir/build.make:156: recipe for target 'Kinect2CaptureYM' failed
make[2]: *** [Kinect2CaptureYM] Error 1
CMakeFiles/Makefile2:190: recipe for target 'CMakeFiles/Kinect2CaptureYM.dir/all' failed
make[1]: *** [CMakeFiles/Kinect2CaptureYM.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

So my make isn't able to link the the freenec2 lib. But I don't understand why as I put this in my makefile:

FIND_PACKAGE(freenect2 REQUIRED)
LIST(APPEND INCLUDE_DIRS ${FREENECT2_INCLUDE_DIRS})
LIST(APPEND LIBRARIES    ${FREENECT2_LIBRARIES})

Does someone know how to link it correctly ? I'm really stuck beacause of that :/

If you need anything else just ask, thx!

PS : The most important things in my code are (enough to make the make crash):

  • the include : #include <libfreenect2/libfreenect2.hpp>
  • the declaration : libfreenect2::Freenect2 freenect2;
Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
Bastienm
  • 363
  • 2
  • 16
  • It depends which `FindFreenect2.cmake` module do you have (it is used by `find_package(freenect2)` call). E.g., [this one](https://github.com/giacomodabisias/libfreenect2pclgrabber/blob/master/modules/FindFreenect2.cmake) sets `FREENECT2_LIBRARY` variable, not a `FREENECT2_LIBRARIES`. – Tsyvarev Apr 10 '17 at 19:20
  • My .cmake is available here " https://drive.google.com/open?id=0B0h7UjL2CnN-SmpsalIyVkdsS1U". I'll give it a try thx ! – Bastienm Apr 11 '17 at 15:03
  • Ok big thx ! You taught a few things about CMake and how to fill it, the make part is now working ! – Bastienm Apr 11 '17 at 15:19

0 Answers0