Search code examples
c++opencvcmakemakefilewindows-subsystem-for-linux

How do I resolve this OpenCV Installation error


I was trying to install OpenCV in my project, I followed the tutorial here. I'm running a Ubuntu 20.04.6 LTS on a WSL on Windows 10.

The problem I'm encountering is during the make command in the build directory, here's the cropped output:

[ 21%] Built target opencv_highgui_plugins
[ 21%] Built target opencv_dnn_plugins
[ 21%] Built target opencv_videoio_plugins
[ 21%] Built target ittnotify
[ 21%] Built target ippiw
[ 21%] Built target libopenjp2
[ 21%] Built target ade
[ 21%] Built target libwebp
[ 21%] Built target libprotobuf
[ 21%] Built target IlmImf
[ 21%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/parallel_impl.cpp.o
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/include/immintrin.h:43,
                 from /usr/lib/gcc/x86_64-linux-gnu/9/include/x86intrin.h:32,
                 from /home/andrea/Code/AI/esercitazione4-23-24/opencv/modules/core/src/parallel_impl.cpp:43:
/usr/lib/gcc/x86_64-linux-gnu/9/include/xsaveintrin.h:3:10: error: stray ‘\’ in program
    3 |        */\m* */\M*
      |          ^
/usr/lib/gcc/x86_64-linux-gnu/9/include/xsaveintrin.h:3:16: error: stray ‘\’ in program
    3 |        */\m* */\M*
      |                ^
...
      |          ^
/usr/lib/gcc/x86_64-linux-gnu/9/include/xsaveoptintrin.h:50:43: error: missing terminating " character
   50 | |/\Z| \Z \Z ignore differences in Unicode "combi
      |                                           ^~~~~~
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/include/immintrin.h:47,
                 from /usr/lib/gcc/x86_64-linux-gnu/9/include/x86intrin.h:32,
                 from /home/andrea/Code/AI/esercitazione4-23-24/opencv/modules/core/src/parallel_impl.cpp:43:
/usr/lib/gcc/x86_64-linux-gnu/9/include/xsavesintrin.h:5:10: error: stray ‘\’ in program
    5 |        */\+*
      |          ^
...
/usr/lib/gcc/x86_64-linux-gnu/9/include/xsavesintrin.h:58:13: error: stray ‘@’ in program
   58 |  foo\(bar\)\@=foo nothing
      |             ^
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/include/immintrin.h:49,
                 from /usr/lib/gcc/x86_64-linux-gnu/9/include/x86intrin.h:32,
                 from /home/andrea/Code/AI/esercitazione4-23-24/opencv/modules/core/src/parallel_impl.cpp:43:
/usr/lib/gcc/x86_64-linux-gnu/9/include/xsavecintrin.h:1:9: error: missing terminating ' character
    1 | skeyword'.
      |         ^~
...
/usr/lib/gcc/x86_64-linux-gnu/9/include/xsavecintrin.h:42:24: error: stray ‘\’ in program
   42 |   or  concat \& concat \& concat
      |                        ^
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/include/immintrin.h:51,
                 from /usr/lib/gcc/x86_64-linux-gnu/9/include/x86intrin.h:32,
                 from /home/andrea/Code/AI/esercitazione4-23-24/opencv/modules/core/src/parallel_impl.cpp:43:
/usr/lib/gcc/x86_64-linux-gnu/9/include/avxintrin.h:11:24: error: missing terminating ' character
   11 | Long-time Vim users won't use menus much.  But the power is in adding your own
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
/usr/lib/gcc/x86_64-linux-gnu/9/include/avxintrin.h:1451:2: error: #endif without #if
 1451 | #endif /* _AVXINTRIN_H_INCLUDED */
      |  ^~~~~
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/include/immintrin.h:85,
                 from /usr/lib/gcc/x86_64-linux-gnu/9/include/x86intrin.h:32,
                 from /home/andrea/Code/AI/esercitazione4-23-24/opencv/modules/core/src/parallel_impl.cpp:43:
/usr/lib/gcc/x86_64-linux-gnu/9/include/avx512vpopcntdqintrin.h:1:4: error: stray ‘`’ in program
    1 | -| `
      |    ^
...
/usr/lib/gcc/x86_64-linux-gnu/9/include/avx512vpopcntdqvlintrin.h:81:15: error: missing terminating " character
   81 | copied to the "* register.
      |               ^~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/include/immintrin.h:103,
                 from /usr/lib/gcc/x86_64-linux-gnu/9/include/x86intrin.h:32,
                 from /home/andrea/Code/AI/esercitazione4-23-24/opencv/modules/core/src/parallel_impl.cpp:43:
/usr/lib/gcc/x86_64-linux-gnu/9/include/bmiintrin.h:25:22: error: missing terminating ' character
   25 | is the window manager's job.  But if compiled with GTK+ 2 support, Vim helps
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
/usr/lib/gcc/x86_64-linux-gnu/9/include/bmiintrin.h:143:2: error: #endif without #if
  143 | #endif /* _BMIINTRIN_H_INCLUDED */
      |  ^~~~~
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/include/immintrin.h:105,
                 from /usr/lib/gcc/x86_64-linux-gnu/9/include/x86intrin.h:32,
                 from /home/andrea/Code/AI/esercitazione4-23-24/opencv/modules/core/src/parallel_impl.cpp:43:
/usr/lib/gcc/x86_64-linux-gnu/9/include/bmi2intrin.h:25:9: error: missing terminating ' character
   25 | Since it's a CSS, they can be rewritten using shorthand: >
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
/usr/lib/gcc/x86_64-linux-gnu/9/include/bmi2intrin.h:109:5: error: missing terminating ' character
  109 | that's not available in the plain GTK+ GUI:  Interaction with the session
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/include/immintrin.h:109,
                 from /usr/lib/gcc/x86_64-linux-gnu/9/include/x86intrin.h:32,
                 from /home/andrea/Code/AI/esercitazione4-23-24/opencv/modules/core/src/parallel_impl.cpp:43:
/usr/lib/gcc/x86_64-linux-gnu/9/include/f16cintrin.h:1:33: error: too many decimal points in number
    1 | *if_ole.txt*    For Vim version 8.1.  Last change: 2019 May 05
      |                                 ^~~~
...
/usr/lib/gcc/x86_64-linux-gnu/9/include/f16cintrin.h:89:30: error: missing terminating ' character
   89 |  Twelve = Vim.Eval("6 + 6")  ' Note this is a STRING
      |                              ^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/include/immintrin.h:113,
                 from /usr/lib/gcc/x86_64-linux-gnu/9/include/x86intrin.h:32,
                 from /home/andrea/Code/AI/esercitazione4-23-24/opencv/modules/core/src/parallel_impl.cpp:43:
/usr/lib/gcc/x86_64-linux-gnu/9/include/xtestintrin.h:5:2: error: stray ‘\’ in program
    5 |  \(an\_s\+\)\@<=file "file" after "an" and white space or an
      |  ^
...
/usr/lib/gcc/x86_64-linux-gnu/9/include/xtestintrin.h:34:6: error: stray ‘@’ in program
   34 |   /<\@1<=span
      |      ^
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/include/immintrin.h:43,
                 from /usr/lib/gcc/x86_64-linux-gnu/9/include/x86intrin.h:32,
                 from /home/andrea/Code/AI/esercitazione4-23-24/opencv/modules/core/src/parallel_impl.cpp:43:
/usr/lib/gcc/x86_64-linux-gnu/9/include/xsaveintrin.h:1:1: error: ‘cter’ does not name a type
    1 | cter is taken literally or not depends on the 'magic' option and the
      | ^~~~
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/build.make:999: modules/core/CMakeFiles/opencv_core.dir/src/parallel_impl.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1703: modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

There's also the full version here, I can't paste it entirely here since it's too long.

I tried sudo update and sudo upgrade, I tried to update the WSL, to restart it, to make clean and then retry. I also tried to comment these lines in the CMakeLists in opencv/modules/core:

ocv_add_dispatched_file_force_all(test_intrin128 TEST SSE2 SSE3 SSSE3 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX)
ocv_add_dispatched_file_force_all(test_intrin256 TEST AVX2 AVX512_SKX LASX)
ocv_add_dispatched_file_force_all(test_intrin512 TEST AVX512_SKX)

but the same error pops up, and here's the CMakeLists.


Solution

  • Instead of installing it from source you could just install it using:

    sudo apt install libopencv-dev python3-opencv