Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make failed - Compiling examples - Undefined References #7

Closed
shreks7 opened this issue Oct 30, 2017 · 6 comments
Closed

Make failed - Compiling examples - Undefined References #7

shreks7 opened this issue Oct 30, 2017 · 6 comments

Comments

@shreks7
Copy link

shreks7 commented Oct 30, 2017

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

  • Jetson TX1 with Jetpack 3.1
  • L4T 28.1
  • CUDA-8.0
  • OpenCV 3.3.0
@madebyollin
Copy link

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
Copy link
Owner

yunchih commented Nov 9, 2017

@madebyollin Thanks for the kind instructions!

@yunchih yunchih closed this as completed Nov 9, 2017
@connorsoohoo
Copy link

connorsoohoo commented Jul 26, 2018

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
Copy link

[ 73%] Linking CXX executable rgbd_tum
../lib/libORB_SLAM2_CUDA.so: undefined reference to cv::cuda::createGaussianFilter(int, int, cv::Size_<int>, 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, cv::cuda::Stream&)'
../lib/libORB_SLAM2_CUDA.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_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
Copy link

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
Copy link

cyizhuo commented Jan 16, 2024

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:

  • ubuntu 18.04
  • GPU 3090
  • opencv 4.2
  • cuda 11.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants