Closed amiltonwong closed 9 years ago
One way to debug it might be to look at the link command you're running. See CMakeFiles/InfiniTAM.dir/link.txt
in your build directory. That should tell you which OpenNI library (if any) you're linking against, e.g. mine looks like this:
/usr/bin/c++ -fPIC -O3 -march=native -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing -stdlib=libstdc++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names -stdlib=libstdc++ CMakeFiles/InfiniTAM.dir/InfiniTAM.cpp.o -o InfiniTAM Engine/libEngine.a Utils/libUtils.a -framework GLUT -framework Cocoa -framework AGL -framework OpenGL ITMLib/libITMLib.a Utils/libUtils.a /Developer/NVIDIA/CUDA-5.5/lib/libcudart.dylib -Wl,-rpath -Wl,/Developer/NVIDIA/CUDA-5.5/lib /Users/stuart/Downloads/OpenNI-MacOSX-x64-2.2/Redist/libOpenNI2.dylib -Wl,-rpath,/Developer/NVIDIA/CUDA-5.5/lib
What does your link command look like? Are you correctly linking against the OpenNI library? (Common issues include specifying the wrong path etc.) Is it the right one, built for the right architecture?
(Sometimes GCC linker errors can also be caused by linking libraries in the wrong order, but that shouldn't be the case here because you're just building InfiniTAM out of the box (I assume) and it's built regularly using GCC during development.)
@sgolodetz Thanks for your reply. CMakeFiles/InfiniTAM.dir/link.txt in my build directory is as follows (my system is ubuntu 12.04(64bit)):
/usr/bin/c++ -fPIC -O3 -march=native -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing CMakeFiles/InfiniTAM.dir/InfiniTAM.cpp.o -o InfiniTAM -rdynamic Engine/libEngine.a Utils/libUtils.a -lglut -lXmu -lXi -lGLU -lGL -lSM -lICE -lX11 -lXext ITMLib/libITMLib.a Utils/libUtils.a /usr/local/cuda-5.5/lib64/libcudart.so -lcuda -lOpenNI -Wl,-rpath,/usr/local/cuda-5.5/lib64
You're right. the option '-lOpenNI' may not be recognized by the system. The location of OpenNI2 in my system is '/root/Download/OpenNI2'. Could you tell me how I should modify the CMakeFiles/InfiniTAM.dir/link.txt file?
THX~
Best regards, Milton
@amiltonwong You shouldn't modify the link.txt file directly - it's auto-generated by CMake, so any changes you make to it will be overwritten. However, you could try running a modified version of that link command from the command line in your build directory to investigate the problem.
In particular, see what happens when you hard-code the path to your OpenNI library in your linker command:
/usr/bin/c++ -fPIC -O3 -march=native -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing CMakeFiles/InfiniTAM.dir/InfiniTAM.cpp.o -o InfiniTAM -rdynamic Engine/libEngine.a Utils/libUtils.a -lglut -lXmu -lXi -lGLU -lGL -lSM -lICE -lX11 -lXext ITMLib/libITMLib.a Utils/libUtils.a /usr/local/cuda-5.5/lib64/libcudart.so -lcuda /root/Download/OpenNI2/[whatever the path to the library is] -Wl,-rpath,/usr/local/cuda-5.5/lib64
If that then works, you may just be setting the path wrong in CMake. Take a look at the variable OpenNI_LIBRARY in the advanced view in ccmake (press 't' to toggle advanced mode and scroll down the bottom). If it's not /root/Download/OpenNI2/[whatever the path to the library is], set it to that. Also make sure that OpenNI_INCLUDE_DIR is correctly set. Then reconfigure, regenerate and build.
It's best if you run cmake as follows:
cmake /path/to/InfiniTAM -DOPEN_NI_ROOT=/path/to/OpenNI2/
(I think the above error messages indicate that you have OpenNI 1 installed in /usr/lib or /usr/local/lib. The cmake systems finds a libOpenNI.so somewhere there and then tries to link to that. It should really test whether the detected OpenNI is v1 or v2.)
Or just do what @olafkaehler said since he's around :) He knows more than I do...
Thank you very much you all @sgolodetz @olafkaehler @sgolodetz, I practice your suggestion. And it built successfully by using command:
/usr/bin/c++ -fPIC -O3 -march=native -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing CMakeFiles/InfiniTAM.dir/InfiniTAM.cpp.o -o InfiniTAM -rdynamic Engine/libEngine.a Utils/libUtils.a -lglut -lXmu -lXi -lGLU -lGL -lSM -lICE -lX11 -lXext ITMLib/libITMLib.a Utils/libUtils.a /usr/local/cuda-5.5/lib64/libcudart.so -lcuda /root/Downloads/OpenNI2/Bin/x64-Release/libOpenNI2.so -Wl,-rpath,/usr/local/cuda-5.5/lib64
And then I modified the OpenNI_LIBRARY option in ccmake, and then built it successfully.
@olafkaehler, you're right. My previous linking issue is due to OpenNI 1 installed in /usr/lib.
THX you all :)
just change the CMakeLists.txt find_package(OpenNI QUIET) to find_package(OpenNI2 QUIET)
Dear all,
I had followed the install step but came across the following build error: (It seems the linking to openni2 issue but I had built openni2 successfully before)
[ 96%] Built target Engine Scanning dependencies of target InfiniTAM [100%] Building CXX object CMakeFiles/InfiniTAM.dir/InfiniTAM.cpp.o Linking CXX executable InfiniTAM Engine/libEngine.a(OpenNIEngine.cpp.o): In function, ITMLib::Vector2)':
OpenNIEngine.cpp:(.text+0x883): undefined reference to
openni::OpenNI::waitForAnyStream(openni::VideoStream**, int, int*, int) [clone .constprop.32]': OpenNIEngine.cpp:(.text+0x1e5): undefined reference to
oniWaitForAnyStream' Engine/libEngine.a(OpenNIEngine.cpp.o): In functionInfiniTAM::Engine::OpenNIEngine::getImages(ITMLib::Objects::ITMView*)': OpenNIEngine.cpp:(.text+0x38c): undefined reference to
oniStreamReadFrame' OpenNIEngine.cpp:(.text+0x3a2): undefined reference tooniFrameRelease' OpenNIEngine.cpp:(.text+0x3d4): undefined reference to
oniStreamReadFrame' OpenNIEngine.cpp:(.text+0x3ea): undefined reference tooniFrameRelease' Engine/libEngine.a(OpenNIEngine.cpp.o): In function
InfiniTAM::Engine::OpenNIEngine::OpenNIEngine(char const, char const, bool, ITMLib::Vector2oniInitialize' OpenNIEngine.cpp:(.text+0x888): undefined reference to
oniGetExtendedError' OpenNIEngine.cpp:(.text+0x8ef): undefined reference tooniDeviceSetProperty' OpenNIEngine.cpp:(.text+0x91e): undefined reference to
oniDeviceSetProperty' OpenNIEngine.cpp:(.text+0x951): undefined reference tooniDeviceSetProperty' OpenNIEngine.cpp:(.text+0x96c): undefined reference to
oniDeviceCreateStream' OpenNIEngine.cpp:(.text+0x979): undefined reference tooniGetExtendedError' OpenNIEngine.cpp:(.text+0x9b3): undefined reference to
oniDeviceCreateStream' OpenNIEngine.cpp:(.text+0x9c0): undefined reference tooniGetExtendedError' OpenNIEngine.cpp:(.text+0x9ff): undefined reference to
oniShutdown' OpenNIEngine.cpp:(.text+0xa79): undefined reference tooniStreamGetSensorInfo' OpenNIEngine.cpp:(.text+0xad6): undefined reference to
oniStreamIsPropertySupported' OpenNIEngine.cpp:(.text+0xaf1): undefined reference tooniStreamIsPropertySupported' OpenNIEngine.cpp:(.text+0xcae): undefined reference to
oniStreamSetProperty' OpenNIEngine.cpp:(.text+0xcea): undefined reference tooniStreamSetProperty' OpenNIEngine.cpp:(.text+0xd07): undefined reference to
oniStreamStart' OpenNIEngine.cpp:(.text+0xda9): undefined reference tooniDeviceOpen' OpenNIEngine.cpp:(.text+0xdb6): undefined reference to
oniGetExtendedError' OpenNIEngine.cpp:(.text+0xe39): undefined reference tooniStreamGetSensorInfo' OpenNIEngine.cpp:(.text+0xe96): undefined reference to
oniStreamIsPropertySupported' OpenNIEngine.cpp:(.text+0xeb1): undefined reference tooniStreamIsPropertySupported' OpenNIEngine.cpp:(.text+0x1075): undefined reference to
oniStreamSetProperty' OpenNIEngine.cpp:(.text+0x10b7): undefined reference tooniStreamSetProperty' OpenNIEngine.cpp:(.text+0x10d4): undefined reference to
oniStreamStart' OpenNIEngine.cpp:(.text+0x116a): undefined reference tooniDeviceGetSensorInfo' OpenNIEngine.cpp:(.text+0x11da): undefined reference to
oniDeviceGetSensorInfo' OpenNIEngine.cpp:(.text+0x1251): undefined reference tooniGetExtendedError' OpenNIEngine.cpp:(.text+0x12e9): undefined reference to
oniGetExtendedError' OpenNIEngine.cpp:(.text+0x1364): undefined reference tooniStreamDestroy' OpenNIEngine.cpp:(.text+0x1374): undefined reference to
oniStreamDestroy' OpenNIEngine.cpp:(.text+0x16f7): undefined reference tooniDeviceGetInfo' OpenNIEngine.cpp:(.text+0x1705): undefined reference to
oniDeviceIsPropertySupported' OpenNIEngine.cpp:(.text+0x171c): undefined reference tooniDeviceIsPropertySupported' OpenNIEngine.cpp:(.text+0x1733): undefined reference to
oniDeviceIsCommandSupported' OpenNIEngine.cpp:(.text+0x1763): undefined reference tooniDeviceIsPropertySupported' OpenNIEngine.cpp:(.text+0x1901): undefined reference to
oniDeviceIsPropertySupported' OpenNIEngine.cpp:(.text+0x1918): undefined reference tooniDeviceIsCommandSupported' Engine/libEngine.a(OpenNIEngine.cpp.o): In function
InfiniTAM::Engine::OpenNIEngine::~OpenNIEngine()': OpenNIEngine.cpp:(.text+0x1976): undefined reference tooniStreamStop' OpenNIEngine.cpp:(.text+0x19ea): undefined reference to
oniStreamStop' OpenNIEngine.cpp:(.text+0x1ab6): undefined reference tooniFrameRelease' OpenNIEngine.cpp:(.text+0x1ad2): undefined reference to
oniFrameRelease' OpenNIEngine.cpp:(.text+0x1c84): undefined reference tooniShutdown' OpenNIEngine.cpp:(.text+0x1ca4): undefined reference to
oniStreamDestroy' OpenNIEngine.cpp:(.text+0x1cb4): undefined reference tooniStreamDestroy' OpenNIEngine.cpp:(.text+0x1cc1): undefined reference to
oniDeviceClose' OpenNIEngine.cpp:(.text+0x1cd4): undefined reference tooniStreamDestroy' OpenNIEngine.cpp:(.text+0x1ce4): undefined reference to
oniDeviceClose' OpenNIEngine.cpp:(.text+0x1cf4): undefined reference tooniStreamDestroy' OpenNIEngine.cpp:(.text+0x1d77): undefined reference to
oniFrameRelease' Engine/libEngine.a(OpenNIEngine.cpp.o): In functionopenni::VideoStream::~VideoStream()': OpenNIEngine.cpp:(.text._ZN6openni11VideoStreamD2Ev[_ZN6openni11VideoStreamD5Ev]+0x74): undefined reference to
oniStreamDestroy' Engine/libEngine.a(OpenNIEngine.cpp.o): In functionopenni::Device::~Device()': OpenNIEngine.cpp:(.text._ZN6openni6DeviceD2Ev[_ZN6openni6DeviceD5Ev]+0xa4): undefined reference to
oniDeviceClose' collect2: ld returned 1 exit status make[2]: * [InfiniTAM] Error 1 make[1]: * [CMakeFiles/InfiniTAM.dir/all] Error 2 make: *\ [all] Error 2Could someone give me suggestions to fix it?
Best regards, Milton