opencv / opencv

Open Source Computer Vision Library
https://opencv.org
Apache License 2.0
79k stars 55.81k forks source link

Compiling error with TBB task_arena_base #10768

Closed alealv closed 6 years ago

alealv commented 6 years ago

CMake output:

General configuration for OpenCV 3.4.0-dev =====================================
  Version control:               3.4.0-228-g203dc3b

  Extra modules:
    Location (extra):            /home/alejandroalvarez/Software/opencv_contrib/modules
    Version control (extra):     3.4.0-33-gcdfcd0b

  Platform:
    Timestamp:                   2018-02-02T18:28:22Z
    Host:                        Linux 4.13.0-31-generic x86_64
    CMake:                       3.5.1
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release

  CPU/HW features:
    Baseline:                    SSE SSE2 SSE3
      requested:                 SSE3
    Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
      requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
      SSE4_1 (3 files):          + SSSE3 SSE4_1
      SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (9 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
      AVX512_SKX (1 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_SKX

  C/C++:
    Built as dynamic libs?:      NO
    C++11:                       YES
    C++ Compiler:                /usr/bin/c++  (ver 5.4.0)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):
    Linker flags (Debug):
    ccache:                      NO
    Precompiled headers:         YES
    Extra dependencies:          /opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64/libmkl_intel_lp64.so /opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64/libmkl_sequential.so /opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64/libmkl_core.so -lpthread -lm -ldl gtk-3 gdk-3 pangocairo-1.0 pango-1.0 atk-1.0 cairo-gobject cairo gdk_pixbuf-2.0 gio-2.0 /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/x86_64-linux-gnu/libpng.so gstbase-0.10 gstreamer-0.10 gobject-2.0 gmodule-2.0 gthread-2.0 glib-2.0 xml2 freetype harfbuzz /usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5.so /usr/lib/x86_64-linux-gnu/libpthread.so /usr/lib/x86_64-linux-gnu/libsz.so /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/x86_64-linux-gnu/libdl.so /usr/lib/x86_64-linux-gnu/libm.so dl m pthread rt /opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7/libtbb.so /opt/intel/ipp/lib/intel64/libippcv.so /opt/intel/ipp/lib/intel64/libippi.so /opt/intel/ipp/lib/intel64/libippcc.so /opt/intel/ipp/lib/intel64/libipps.so /opt/intel/ipp/lib/intel64/libippvm.so /opt/intel/ipp/lib/intel64/libippcore.so
    3rdparty dependencies:       ittnotify libprotobuf libwebp libtiff libjasper IlmImf ippiw

  OpenCV modules:
    To be built:                 aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dpm face features2d flann freetype fuzzy hdf highgui img_hash imgcodecs imgproc java java_bindings_generator line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 python3 python_bindings_generator reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
    Disabled:                    js world
    Disabled by dependency:      -
    Unavailable:                 cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv dnn_modern matlab ovis sfm viz
    Applications:                apps
    Documentation:               NO
    Non-free algorithms:         NO

  GUI: 
    GTK+:                        YES (ver 3.18.9)
      GThread :                  YES (ver 2.48.2)
      GtkGlExt:                  NO
    VTK support:                 NO

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
    JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
    WEBP:                        build (ver encoder: 0x020e)
    PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.54)
    TIFF:                        build (ver 42 - 4.0.9)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)

  Video I/O:
    DC1394:                      NO
    FFMPEG:                      NO
      avcodec:                   NO
      avformat:                  NO
      avutil:                    NO
      swscale:                   NO
      avresample:                NO
    GStreamer:                   NO
    libv4l/libv4l2:              NO
    v4l/v4l2:                    linux/videodev2.h
    gPhoto2:                     NO

  Parallel framework:            TBB (ver 2018.0 interface 10000)

  Trace:                         YES (with Intel ITT)

  Other third-party libraries:
    Intel IPP:                   2018.0.0 [2018.0.0]
           at:                   /opt/intel/ipp
       linked:                   dynamic
    Intel IPP IW:                sources (2017.0.3)
              at:                /home/alejandroalvarez/Software/opencv/build/3rdparty/ippicv/ippicv_lnx/../ippiw_lnx/
    Lapack:                      YES (/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64/libmkl_intel_lp64.so /opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64/libmkl_sequential.so /opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64/libmkl_core.so /opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64/libmkl_intel_lp64.so /opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64/libmkl_sequential.so /opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64/libmkl_core.so /opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64/libmkl_intel_lp64.so /opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64/libmkl_sequential.so /opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64/libmkl_core.so -lpthread -lm -ldl)
    Eigen:                       NO
    Custom HAL:                  NO

  NVIDIA CUDA:                   NO

  OpenCL:                        YES (no extra features)
    Include path:                /home/alejandroalvarez/Software/opencv/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python 2:
    Interpreter:                 /usr/bin/python2.7 (ver 2.7.12)
    Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.12)
    numpy:                       /home/alejandroalvarez/.local/lib/python2.7/site-packages/numpy/core/include (ver 1.14.0)
    packages path:               lib/python2.7/dist-packages

  Python 3:
    Interpreter:                 /usr/bin/python3 (ver 3.5.2)
    Libraries:                   /usr/lib/x86_64-linux-gnu/libpython3.5m.so (ver 3.5.2)
    numpy:                       /home/alejandroalvarez/.local/lib/python3.5/site-packages/numpy/core/include (ver 1.14.0)
    packages path:               lib/python3.5/dist-packages

  Python (for build):            /usr/bin/python2.7

  Java:                          
    ant:                         /usr/bin/ant (ver 1.9.6)
    JNI:                         /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include/linux /usr/lib/jvm/default-java/include
    Java wrappers:               YES
    Java tests:                  NO

  Matlab:                        NO

  Install to:                    /usr/local

Detailed description

I experiencing a problem when compiling OpenCV with TBB libraries after this merge https://github.com/opencv/opencv/pull/10697

Compiling output

$make -j1
[  1%] Built target gen-pkgconfig
[  4%] Built target libtiff
[ 13%] Built target libwebp
[ 16%] Built target libjasper
[ 21%] Built target IlmImf
[ 23%] Built target ippiw
[ 29%] Built target libprotobuf
[ 29%] Built target ittnotify
[ 29%] Built target opencv_core_pch_dephelp
[ 30%] Built target pch_Generate_opencv_core
[ 35%] Built target opencv_core
[ 35%] Built target opencv_flann_pch_dephelp
[ 36%] Built target pch_Generate_opencv_flann
[ 36%] Built target opencv_flann
[ 36%] Built target opencv_hdf_pch_dephelp
[ 36%] Built target pch_Generate_opencv_hdf
[ 36%] Built target opencv_hdf
[ 36%] Built target opencv_imgproc_pch_dephelp
[ 37%] Built target pch_Generate_opencv_imgproc
[ 42%] Built target opencv_imgproc
[ 42%] Built target opencv_ml_pch_dephelp
[ 42%] Built target pch_Generate_opencv_ml
[ 44%] Built target opencv_ml
[ 44%] Built target opencv_objdetect_pch_dephelp
[ 44%] Built target pch_Generate_opencv_objdetect
[ 45%] Built target opencv_objdetect
[ 45%] Built target opencv_phase_unwrapping_pch_dephelp
[ 45%] Built target pch_Generate_opencv_phase_unwrapping
[ 45%] Built target opencv_phase_unwrapping
[ 46%] Built target opencv_photo_pch_dephelp
[ 47%] Built target pch_Generate_opencv_photo
[ 48%] Built target opencv_photo
[ 48%] Built target opencv_plot_pch_dephelp
[ 48%] Built target pch_Generate_opencv_plot
[ 48%] Built target opencv_plot
[ 48%] Built target opencv_reg_pch_dephelp
[ 48%] Built target pch_Generate_opencv_reg
[ 49%] Built target opencv_reg
[ 49%] Built target opencv_surface_matching_pch_dephelp
[ 49%] Built target pch_Generate_opencv_surface_matching
[ 50%] Built target opencv_surface_matching
[ 50%] Built target opencv_video_pch_dephelp
[ 50%] Built target pch_Generate_opencv_video
[ 51%] Built target opencv_video
[ 52%] Built target opencv_xphoto
[ 52%] Built target opencv_dnn_pch_dephelp
[ 52%] Built target pch_Generate_opencv_dnn
[ 57%] Built target opencv_dnn
[ 57%] Built target opencv_freetype_pch_dephelp
[ 57%] Built target pch_Generate_opencv_freetype
[ 57%] Built target opencv_freetype
[ 57%] Built target opencv_fuzzy_pch_dephelp
[ 57%] Built target pch_Generate_opencv_fuzzy
[ 58%] Built target opencv_fuzzy
[ 58%] Built target opencv_img_hash_pch_dephelp
[ 58%] Built target pch_Generate_opencv_img_hash
[ 59%] Built target opencv_img_hash
[ 59%] Built target opencv_imgcodecs_pch_dephelp
[ 59%] Built target pch_Generate_opencv_imgcodecs
[ 61%] Built target opencv_imgcodecs
[ 61%] Built target opencv_shape_pch_dephelp
[ 61%] Built target pch_Generate_opencv_shape
[ 62%] Built target opencv_shape
[ 62%] Built target opencv_videoio_pch_dephelp
[ 62%] Built target pch_Generate_opencv_videoio
[ 63%] Built target opencv_videoio
[ 63%] Built target opencv_xobjdetect_pch_dephelp
[ 64%] Built target pch_Generate_opencv_xobjdetect
[ 64%] Built target opencv_xobjdetect
[ 64%] Built target opencv_highgui_pch_dephelp
[ 64%] Built target pch_Generate_opencv_highgui
[ 64%] Built target opencv_highgui
Scanning dependencies of target opencv_waldboost_detector
[ 64%] Building CXX object modules/xobjdetect/tools/waldboost_detector/CMakeFiles/opencv_waldboost_detector.dir/waldboost_detector.cpp.o
[ 64%] Linking CXX executable ../../../../bin/opencv_waldboost_detector
../../../../lib/libopencv_core.a(parallel.cpp.o): In function `cv::getNumThreads()':
parallel.cpp:(.text._ZN2cv13getNumThreadsEv+0x38): undefined reference to `tbb::interface7::internal::task_arena_base::internal_max_concurrency(tbb::interface7::task_arena const*)'
collect2: error: ld returned 1 exit status
modules/xobjdetect/tools/waldboost_detector/CMakeFiles/opencv_waldboost_detector.dir/build.make:127: recipe for target 'bin/opencv_waldboost_detector' failed
make[2]: *** [bin/opencv_waldboost_detector] Error 1
CMakeFiles/Makefile2:5196: recipe for target 'modules/xobjdetect/tools/waldboost_detector/CMakeFiles/opencv_waldboost_detector.dir/all' failed
make[1]: *** [modules/xobjdetect/tools/waldboost_detector/CMakeFiles/opencv_waldboost_detector.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
alalek commented 6 years ago
  1. Grab linker command line (make VERBOSE=1)
  2. Run linker with verbose option to see that is wrong (-Wl,--verbose).

I guess you have installed system libtbb.so.2. To fix this, ensure that you call tbbvars.sh before "make" (it should setup "LIBRARY_PATH" environment variable).

alealv commented 6 years ago

I've installed the last intel performance libraries 2018.1.163

So I ran manually source /opt/intel/compilers_and_libraries_2018.1.163/linux/tbb/bin/tbbvars.sh intel64 before compiling. But I've got the same output

[ 64%] Linking CXX executable ../../../../bin/opencv_waldboost_detector cd /home/alejandroalvarez/Software/opencv/build/modules/xobjdetect/tools/waldboost_detector && /usr/bin/cmake -E cmake_link_script CMakeFiles/opencv_waldboost_detector.dir/link.txt --verbose=1 /usr/bin/c++ -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG -Wl,--gc-sections CMakeFiles/opencv_waldboost_detector.dir/waldboost_detector.cpp.o -o ../../../../bin/opencv_waldboost_detector -L/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64 -rdynamic ../../../../lib/libopencv_core.a ../../../../lib/libopencv_imgproc.a ../../../../lib/libopencv_imgcodecs.a ../../../../lib/libopencv_videoio.a ../../../../lib/libopencv_highgui.a ../../../../lib/libopencv_xobjdetect.a ../../../../lib/libopencv_videoio.a -lgstbase-0.10 -lgstreamer-0.10 -lgmodule-2.0 -lxml2 -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lgthread-2.0 -lglib-2.0 ../../../../lib/libopencv_imgcodecs.a -ljpeg ../../../../3rdparty/lib/liblibwebp.a -lpng ../../../../3rdparty/lib/liblibtiff.a ../../../../3rdparty/lib/liblibjasper.a ../../../../3rdparty/lib/libIlmImf.a ../../../../lib/libopencv_objdetect.a ../../../../lib/libopencv_imgproc.a ../../../../lib/libopencv_core.a -lz -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl ../../../../3rdparty/lib/libittnotify.a -ldl -lm -lpthread -lrt /opt/intel/compilers_and_libraries_2018.1.163/linux/tbb/lib/intel64/gcc4.7/libtbb.so ../../../../3rdparty/lib/libippiw.a /opt/intel/ipp/lib/intel64/libippcv.so /opt/intel/ipp/lib/intel64/libippi.so /opt/intel/ipp/lib/intel64/libippcc.so /opt/intel/ipp/lib/intel64/libipps.so /opt/intel/ipp/lib/intel64/libippvm.so /opt/intel/ipp/lib/intel64/libippcore.so -Wl,-rpath,/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64:/opt/intel/ipp/lib/intel64::::::::::::::: ../../../../lib/libopencv_core.a(parallel.cpp.o): In function cv::getNumThreads()': parallel.cpp:(.text._ZN2cv13getNumThreadsEv+0x38): undefined reference totbb::interface7::internal::task_arena_base::internal_max_concurrency(tbb::interface7::task_arena const*)' collect2: error: ld returned 1 exit status modules/xobjdetect/tools/waldboost_detector/CMakeFiles/opencv_waldboost_detector.dir/build.make:130: recipe for target 'bin/opencv_waldboost_detector' failed make[2]: [bin/opencv_waldboost_detector] Error 1 make[2]: Leaving directory '/home/alejandroalvarez/Software/opencv/build' CMakeFiles/Makefile2:5135: recipe for target 'modules/xobjdetect/tools/waldboost_detector/CMakeFiles/opencv_waldboost_detector.dir/all' failed make[1]: [modules/xobjdetect/tools/waldboost_detector/CMakeFiles/opencv_waldboost_detector.dir/all] Error 2 make[1]: Leaving directory '/home/alejandroalvarez/Software/opencv/build' Makefile:163: recipe for target 'all' failed make: *** [all] Error 2

alalek commented 6 years ago

What LIBRARY_PATH do you have?

$ echo ${LIBRARY_PATH}
/opt/intel/compilers_and_libraries_2018.1.163/linux/tbb/lib/intel64/gcc4.7

Problem is here:

$ cat /opt/intel/tbb/lib/intel64/gcc4.7/libtbb.so
INPUT (libtbb.so.2)

This occasionally redirects linker to system libtbb.so.2 if LIBRARY_PATH is not correct. This leads that you did't use Intel TBB binary really (if you have system one).

BTW, I believe this is very strange way to simulate versioning .so symbolic link (via linker scripts). True Linux way looks like this:

$ ll /usr/lib64/libtbb.so*
lrwxrwxrwx. 1 root root     11 Jun 11  2017 /usr/lib64/libtbb.so -> libtbb.so.2
-rwxr-xr-x. 1 root root 246056 Jun 11  2017 /usr/lib64/libtbb.so.2

Perhaps this should be reported to TBB team (https://github.com/01org/tbb/issues)

alalek commented 6 years ago

Sorry, Looks like LIBRARY_PATH doesn't work well.

Try to add this linker option instead:

-L/opt/intel/compilers_and_libraries_2018.1.163/linux/tbb/lib/intel64/gcc4.7

For example:

cmake -DCMAKE_CXX_FLAGS="-Wl,-L/opt/intel/compilers_and_libraries_2018.1.163/linux/tbb/lib/intel64/gcc4.7" <...>

Example of bad sequence (Fedora 26, -Wl,--verbose):

attempt to open /opt/intel/tbb/lib/intel64/gcc4.7/libtbb.so succeeded
opened script file /opt/intel/tbb/lib/intel64/gcc4.7/libtbb.so
attempt to open libtbb.so.2 failed
attempt to open /usr/lib/gcc/x86_64-redhat-linux/7/libtbb.so.2 failed
attempt to open /usr/lib/gcc/x86_64-redhat-linux/7/../../../../lib64/libtbb.so.2 succeeded
libtbb.so.2 (/usr/lib/gcc/x86_64-redhat-linux/7/../../../../lib64/libtbb.so.2)

Good linker sequence:

attempt to open /opt/intel/tbb/lib/intel64/gcc4.7/libtbb.so succeeded
opened script file /opt/intel/tbb/lib/intel64/gcc4.7/libtbb.so
attempt to open libtbb.so.2 failed
attempt to open /opt/intel/tbb/lib/intel64/gcc4.7//libtbb.so.2 succeeded
libtbb.so.2 (/opt/intel/tbb/lib/intel64/gcc4.7//libtbb.so.2)