yunchih / ORB-SLAM2-GPU2016-final

http://yunchih.github.io/ORB-SLAM2-GPU2016-final/
Other
328 stars 150 forks source link

Make failed - Compiling examples - Undefined References #7

Closed shreks7 closed 7 years ago

shreks7 commented 7 years ago

I am getting this issue when building ORB_SLAM2

[ 83%] Linking CXX executable mono_tum
lib/libORB_SLAM2.so: undefined reference to `cv::cuda::createGaussianFilter(int, int, cv::Size_<int>, double, double, int, int)'
lib/libORB_SLAM2.so: undefined reference to `cv::cuda::copyMakeBorder(cv::_InputArray const&, cv::_OutputArray const&, int, int, int, int, int, cv::Scalar_<double>, cv::cuda::Stream&)'
lib/libORB_SLAM2.so: undefined reference to `cv::cuda::resize(cv::_InputArray const&, cv::_OutputArray const&, cv::Size_<int>, double, double, int, cv::cuda::Stream&)'
lib/libORB_SLAM2.so: undefined reference to `cv::cuda::StreamAccessor::wrapStream(CUstream_st*)'
collect2: error: ld returned 1 exit status
CMakeFiles/mono_tum.dir/build.make:162: recipe for target 'mono_tum' failed
make[2]: *** [mono_tum] Error 1
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/mono_tum.dir/all' failed
make[1]: *** [CMakeFiles/mono_tum.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

My config

madebyollin commented 7 years ago

It sounds like your OpenCV build might have been compiled without CUDA? Check that wherever you installed OpenCV 3.3.0 (e.g. /usr/local/), you have the core/cuda.hpp file (e.g. /usr/local/include/opencv2/core/cuda.hpp), or, alternately, check that the cvconfig.h in either your build folder or your install folder has #define HAVE_CUDA uncommented.

yunchih commented 7 years ago

@madebyollin Thanks for the kind instructions!

connorsoohoo commented 6 years ago

I have the same error but I verified that I installed OpenCV with CUDA. I was previously getting this project to compile but I had to reflash my Tx2 and reinstall all the dependencies. I was originally getting issue #6 but after linking nvToolsExt the shared library still can't see any CUDA references.

sivaariram commented 6 years ago

[ 73%] Linking CXX executable rgbd_tum ../lib/libORB_SLAM2CUDA.so: undefined reference to `cv::cuda::createGaussianFilter(int, int, cv::Size, double, double, int, int)' ../lib/libORB_SLAM2_CUDA.so: undefined reference to cv::cuda::copyMakeBorder(cv::_InputArray const&, cv::_OutputArray const&, int, int, int, int, int, cv::Scalar_<double>, cv::cuda::Stream&)' ../lib/libORB_SLAM2_CUDA.so: undefined reference tocv::cuda::resize(cv::_InputArray const&, cv::OutputArray const&, cv::Size, double, double, int, cv::cuda::Stream&)' ../lib/libORB_SLAM2_CUDA.so: undefined reference to `cv::cuda::StreamAccessor::wrapStream(CUstream_st*)' collect2: error: ld returned 1 exit status CMakeFiles/rgbd_tum.dir/build.make:162: recipe for target 'rgbd_tum' failed make[2]: [rgbd_tum] Error 1 CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/rgbd_tum.dir/all' failed make[1]: [CMakeFiles/rgbd_tum.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2

@madebyollin I am getting the same error. Also I cross checked what you mention in your last comment, cuda.hpp is there inside core/cuda.hpp. cvconfig.h is also cross checked.

arnabsinha commented 5 years ago

Doing the following has solved my problem: change target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} ${EIGEN3_LIBS} ${Pangolin_LIBRARIES} ${PROJECT_SOURCE_DIR}/Thirdparty/DBoW2/lib/libDBoW2.so ${PROJECT_SOURCE_DIR}/Thirdparty/g2o/lib/libg2o.so nvToolsExt ) to target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} ${EIGEN3_LIBS} ${Pangolin_LIBRARIES} ${PROJECT_SOURCE_DIR}/Thirdparty/DBoW2/lib/libDBoW2.so ${PROJECT_SOURCE_DIR}/Thirdparty/g2o/lib/libg2o.so nvToolsExt opencv_cudabgsegm opencv_cudaobjdetect opencv_cudastereo opencv_cudafeatures2d opencv_cudacodec opencv_cudaoptflow opencv_cudalegacy opencv_cudawarping opencv_cudaimgproc opencv_cudafilters )

cyizhuo commented 10 months ago

Thank for the solution, I changed target_link_libraries in main CMakeLists.txt and it worked.

More over, with following env, compile can success with no need to change target_link_libraries: