How do I fix “undefined reference to `cv::cuda::…” linker errors in Eclipse?

asked 2019-05-16 15:02:38 -0500

jp2112 gravatar image

updated 2019-05-16 15:03:40 -0500

Disclaimer: I'm new to this whole Linux and CMake and GPU thing. But I've been using pre-built OpenCV in Windows for a few years.

I recently installed the latest versions of Ubuntu (18.04), OpenCV (4.1.0), Eclipse IDE (Version: 2019-03 (4.11.0)) and CUDA (10.1) for my new Precision 7730 with Quadro P5200. My Eclipse C++/CUDA toolchain project compiles and runs fine using just OpenCV syntax, first using a CMake build without CUDA and more recently a new CMake where I added CUDA support. I think I've followed all installation instructions properly, at least those I could find which deal with recent software versions including the CUDA 10.1 Toolkit.

But now I am trying to replace some of my cv:: functions with cv::cuda:: functions and am getting linker errors. I guess I am missing some libraries, or Eclipse is not knowing where they are. CMake appeared to make everything. What do I need to check and where do I need to look to see what's missing?

All of the solutions I've seen posted are quite old so I can't figure out how to make them apply to my problem.

Here is my Eclipse output when I build the project:

10:42:05 **** Build of configuration Release for project CS3_intfc **** make all Building file: ../src/CS3_intfc.cpp Invoking: NVCC Compiler /usr/local/cuda-10.1/bin/nvcc -I/usr/local/include/opencv4 -O3 --use_fast_math -gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -ccbin g++ -c -o "src/CS3_intfc.o" "../src/CS3_intfc.cpp" Finished building: ../src/CS3_intfc.cpp

Building target: CS3_intfc Invoking: NVCC linker /usr/local/cuda-10.1/bin/nvcc --cudart=static -L/usr/local/lib -ccbin g++ -lGL -lGLU -lglut -gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -o "CS3_intfc" ./src/CS3_intfc.o -lopencv_core -lopencv_calib3d -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_video -lopencv_videoio -lopencv_videostab -lpthread ./src/CS3_intfc.o: In function main':
CS3_intfc.cpp:(.text.startup+0x561e): undefined reference tocv::cuda::subtract(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, int, cv::cuda::Stream&)' CS3_intfc.cpp:(.text.startup+0x56c1): undefined reference to cv::cuda::compare(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, int, cv::cuda::Stream&)'
CS3_intfc.cpp:(.text.startup+0x5768): undefined reference tocv::cuda::compare(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, int, cv::cuda::Stream&)' CS3_intfc.cpp:(.text.startup+0x5805): undefined reference to cv::cuda::add(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, int, cv::cuda::Stream&)'
CS3_intfc.cpp:(.text.startup+0x5843): undefined reference tocv::cuda::sum(cv::_InputArray const&, cv::_InputArray const&)' collect2: error: ld returned 1 exit status makefile:24: recipe for target 'CS3_intfc' failed make: *** [CS3_intfc] Error 1 "make all" terminated with exit code 2. Build might be incomplete.

10:42:09 Build Failed. 2 errors, 0 warnings. (took 4s.17ms)

Here is what I get with "echo $PATH" in a terminal ... (more)

edit retag flag offensive close merge delete