3

Trying to install openCV 3.1, CUDA 8.0.44 on Ubuntu 16.04 by building from the source.

The following are the errors I met during the compilation.

Scanning dependencies of target opencv_test_video
[ 37%] Building CXX object modules/video/CMakeFiles/opencv_test_video.dir/test/test_optflowpyrlk.cpp.o
[ 37%] Building CXX object modules/video/CMakeFiles/opencv_test_video.dir/test/test_accum.cpp.o
[ 37%] Building CXX object modules/video/CMakeFiles/opencv_test_video.dir/test/test_kalman.cpp.o
[ 38%] Building CXX object modules/video/CMakeFiles/opencv_test_video.dir/test/test_ecc.cpp.o
[ 38%] Building CXX object modules/video/CMakeFiles/opencv_test_video.dir/test/test_tvl1optflow.cpp.o
[ 38%] Building CXX object modules/video/CMakeFiles/opencv_test_video.dir/test/test_main.cpp.o
[ 38%] Building CXX object modules/video/CMakeFiles/opencv_test_video.dir/test/test_camshift.cpp.o
[ 38%] Building CXX object modules/video/CMakeFiles/opencv_test_video.dir/test/ocl/test_optflowpyrlk.cpp.o
[ 38%] Building CXX object modules/video/CMakeFiles/opencv_test_video.dir/test/ocl/test_optflow_farneback.cpp.o
[ 38%] Building CXX object modules/video/CMakeFiles/opencv_test_video.dir/test/ocl/test_bgfg_mog2.cpp.o
[ 38%] Building CXX object modules/video/CMakeFiles/opencv_test_video.dir/test/ocl/test_optflow_tvl1flow.cpp.o
[ 38%] Building CXX object modules/video/CMakeFiles/opencv_test_video.dir/test/test_estimaterigid.cpp.o
[ 38%] Linking CXX executable ../../bin/opencv_test_video
//usr/lib/x86_64-linux-gnu/libsoxr.so.0: undefined reference to `GOMP_parallel@GOMP_4.0'
collect2: error: ld returned 1 exit status
modules/video/CMakeFiles/opencv_test_video.dir/build.make:391: recipe for target 'bin/opencv_test_video' failed
make[2]: *** [bin/opencv_test_video] Error 1
CMakeFiles/Makefile2:3336: recipe for target 'modules/video/CMakeFiles/opencv_test_video.dir/all' failed
make[1]: *** [modules/video/CMakeFiles/opencv_test_video.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

I consider the issue is related to the openMP or the ld configuration.

The following are the detailed configuration:

  1. LD_LIBRARY_PATH:

/usr/lib/nvidia-current:/usr/local/cuda/lib64:/usr/local/cuda/lib

  1. GCC version: 5.4.0

  2. CMake configuration command:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_CUBLAS=ON -DCUDA_NVCC_FLAGS="-D_FORCE_INLINES" ..

talonmies
  • 70,661
  • 34
  • 192
  • 269
Yuan Ma
  • 858
  • 2
  • 11
  • 23

2 Answers2

18

Firstly, I thought this problem was caused because I installed Anaconda and put it into my PATH.

Different GCC version are used between Anaconda and System default. For Ubuntu 16.04, the GCC version is 5.4.0 however Anaconda only provides GCC 4 (I can't remember it's 4.4 or 4.8). Although I used the system default gcc to compile opencv, it somehow will find the lib located in Anaconda, which caused the problem.

I think there are two ways to solve this issue.

  1. Method 1: Pass the option -D WITH_OPENMP=ON, or, when using cmake-gui, check the choice WITH-OPENMP.
  2. Method 2: Delete Anaconda from your $PATH and LD_LIBRARY_PATH.
oulenz
  • 1,199
  • 1
  • 15
  • 24
Yuan Ma
  • 858
  • 2
  • 11
  • 23
  • This helped. Thanks! – mahasamatman Nov 27 '16 at 12:10
  • 1
    This also worked for me, thank you for taking the trouble of posting your solution. Note that when using the command line, `-D WITH_OPENMP=ON` is the equivalent option that does the trick. – oulenz Mar 16 '17 at 16:29
  • Passing the option '-D WITH_OPENMP=ON' also worked for me. I was using CUDA 9.1.85-1 on Ubuntu 16.04(GCC 5.4.0) attempting to build opencv 3.4, and my build command was `cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_OPENMP=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_VTK=ON -D WITH_GTK=ON WITH_GTK_2_X=OFF -D WITH_CUBLAS=ON -D WITH_NVCUVID=ON -D WITH_LAPACK=ON -D OPENCV_EXTRA_MODULES_PATH=/my/opencv_contrib/modules/path ..` – David Jung Jan 24 '18 at 00:53
0

I have a similar issue but with another library file usr/lib/x86_64-linux-gnu/libgdcmMSFF.so.2.8: undefined reference to `uuid_generate@UUID_1.0' Look here for my issue. I think you may also got a warning that files in some directories may conflict with libraries in implicit directories:

Solution in my case: I added /usr/lib/x86_64-linux-gnu to LD_LIBRARY_PATH in bashrc file and sourced it. Then, I have moved the libuuid library file under anaconda3/lib to anaconda3/libuuid. No more errors for me and I hope this could work as well.

Akhil
  • 11
  • 2