opencv / opencv-python

Automated CI toolchain to produce precompiled opencv-python, opencv-python-headless, opencv-contrib-python and opencv-contrib-python-headless packages.
https://pypi.org/project/opencv-python/
MIT License
4.53k stars 847 forks source link

Build error: cc1: warning: unrecognized command line option '-Wno-absolute-value' #277

Closed ww9rivers closed 4 years ago

ww9rivers commented 4 years ago

Expected behaviour

Expecting to build a binary package on an Orange Pi 3 running Armbian:

python setup.py bdist_wheel

Actual behaviour

CMake Error at /usr/share/cmake-3.10/Modules/FindQt4.cmake:1320 (message):
  Found unsuitable Qt version "" from NOTFOUND, this code requires Qt 4.x
Call Stack (most recent call first):
  cmake/OpenCVFindLibsGUI.cmake:30 (find_package)
  CMakeLists.txt:669 (include)

-- Configuring incomplete, errors occurred!
See also "/home/weiwang/ai/opencv-python/_skbuild/linux-aarch64-3.6/cmake-build/CMakeFiles/CMakeOutput.log".
See also "/home/weiwang/ai/opencv-python/_skbuild/linux-aarch64-3.6/cmake-build/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
  File "/home/weiwang/env/lib/python3.6/site-packages/skbuild/setuptools_wrap.py", line 574, in setup
    languages=cmake_languages
  File "/home/weiwang/env/lib/python3.6/site-packages/skbuild/cmaker.py", line 232, in configure
    os.path.abspath(CMAKE_BUILD_DIR())))

An error occurred while configuring with CMake.
  Command:
    "cmake" "/home/weiwang/ai/opencv-python/opencv" "-G" "Unix Makefiles" "-DCMAKE_INSTALL_PREFIX:PATH=/home/weiwang/ai/opencv-python/_skbuild/linux-aarch64-3.6/cmake-install" "-DPYTHON_EXECUTABLE:FILEPATH=/home/weiwang/env/bin/python" "-DPYTHON_VERSION_STRING:STRING=3.6.8" "-DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.6m" "-DPYTHON_LIBRARY:FILEPATH=/usr/lib/aarch64-linux-gnu/libpython3.6m.so" "-DSKBUILD:BOOL=TRUE" "-DCMAKE_MODULE_PATH:PATH=/home/weiwang/env/lib/python3.6/site-packages/skbuild/resources/cmake" "-DPYTHON3_EXECUTABLE=/home/weiwang/env/bin/python" "-DBUILD_opencv_python3=ON" "-DOPENCV_SKIP_PYTHON_LOADER=ON" "-DOPENCV_PYTHON3_INSTALL_PATH=python" "-DINSTALL_CREATE_DISTRIB=ON" "-DBUILD_opencv_apps=OFF" "-DBUILD_SHARED_LIBS=OFF" "-DBUILD_TESTS=OFF" "-DBUILD_PERF_TESTS=OFF" "-DBUILD_DOCS=OFF" "-DWITH_QT=4" "-DWITH_V4L=ON" "-DENABLE_PRECOMPILED_HEADERS=OFF" "-DWITH_IPP=OFF" "-DCMAKE_BUILD_TYPE:STRING=Release"
  Source directory:
    /home/weiwang/ai/opencv-python/opencv
  Working directory:
    /home/weiwang/ai/opencv-python/_skbuild/linux-aarch64-3.6/cmake-build
Please see CMake's output for more information.

Found in /home/weiwang/ai/opencv-python/_skbuild/linux-aarch64-3.6/cmake-build/CMakeFiles/CMakeError.log:

===== BUILD LOG =====
Change Dir: /home/weiwang/ai/opencv-python/_skbuild/linux-aarch64-3.6/cmake-build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_d561a/fast"
/usr/bin/make -f CMakeFiles/cmTC_d561a.dir/build.make CMakeFiles/cmTC_d561a.dir/build
make[1]: Entering directory '/home/weiwang/ai/opencv-python/_skbuild/linux-aarch64-3.6/cmake-build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_d561a.dir/src.c.o
/usr/bin/cc   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -Wno-implicit-function-declaration -Wno-uninitialized -Wno-missing-prototypes -Wno-unused-but-set-parameter -Wno-missing-declarations -Wno-unused -Wno-shadow -Wno-sign-compare -Wno-strict-overflow -Wno-pointer-compare  -O3 -DNDEBUG -fPIE   -Wno-absolute-value -o CMakeFiles/cmTC_d561a.dir/src.c.o   -c /home/weiwang/ai/opencv-python/_skbuild/linux-aarch64-3.6/cmake-build/CMakeFiles/CMakeTmp/src.c
/home/weiwang/ai/opencv-python/_skbuild/linux-aarch64-3.6/cmake-build/CMakeFiles/CMakeTmp/src.c:1:0: warning: ignoring #pragma   [-Wunknown-pragmas]
 #pragma

cc1: warning: unrecognized command line option '-Wno-absolute-value'
Linking C executable cmTC_d561a
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_d561a.dir/link.txt --verbose=1
/usr/bin/cc    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fda
ta-sections    -fvisibility=hidden -Wno-implicit-function-declaration -Wno-uninitialized -Wno-missing-prototypes -Wno-unused-but-set-parameter -Wno-missing-declarations -Wno-unused -Wno-shadow -Wno-sign-compare -Wno-strict-overflow -Wno-pointer-compare  -O3 -DNDEBUG    -Wl,--gc-sections  CMakeFiles/cmTC_d561a.dir/src.c.o  -o cmTC_d561a
make[1]: Leaving directory '/home/weiwang/ai/opencv-python/_skbuild/linux-aarch64-3.6/cmake-build/CMakeFiles/CMakeTmp'

===== END =====

Steps to reproduce

skvark commented 4 years ago

This is the actual issue:

CMake Error at /usr/share/cmake-3.10/Modules/FindQt4.cmake:1320 (message):
  Found unsuitable Qt version "" from NOTFOUND, this code requires Qt 4.x
Call Stack (most recent call first):
  cmake/OpenCVFindLibsGUI.cmake:30 (find_package)
  CMakeLists.txt:669 (include)

To turn Qt4 off, use:

export CMAKE_ARGS="-DWITH_QT=OFF"
python setup.py bdist_wheel
ww9rivers commented 4 years ago

Thank you for the response.

Your tip helps getting the build process to installation:

 . . . . . .
-- Installing: /home/weiwang/ai/opencv-python/_skbuild/linux-aarch64-3.6/cmake-install/share/opencv4/lbpcascades/lbpcascade_frontalface_improved.xml
-- Installing: /home/weiwang/ai/opencv-python/_skbuild/linux-aarch64-3.6/cmake-install/share/opencv4/lbpcascades/lbpcascade_profileface.xml
-- Installing: /home/weiwang/ai/opencv-python/_skbuild/linux-aarch64-3.6/cmake-install/share/opencv4/lbpcascades/lbpcascade_silverware.xml
Copying files from CMake output
Traceback (most recent call last):
  File "setup.py", line 392, in <module>
    main()
  File "setup.py", line 214, in main
    cmake_source_dir=cmake_source_dir,
  File "/home/weiwang/env/lib/python3.6/site-packages/skbuild/setuptools_wrap.py", line 604, in setup
    cmake_source_dir, skbuild_kw['cmake_install_dir'])
  File "setup.py", line 304, in _classify_installed_files_override
    if not found: raise Exception("Not found: '%s'" % relpath_re)
Exception: Not found: 'python/cv2[^/]*\.cpython\-36m\-aarch64\-linux\-gnu\.so'

I searched in the folder where I started the build and found no .so file at all.

I have done a clean up and rebuilt everything. Same result.

ww9rivers commented 4 years ago

Going back to retry with libqt4-dev package installed.

skvark commented 4 years ago

That new error is not related to Qt. setup.py is searching for the cv2 binary from that location. It might be located in a different place in your system or the build might have failed and the binary wasn't generated properly. I cannot help much since I have no Orange Pi / Armbian environment available.

ww9rivers commented 4 years ago

Understood. I suppose the build process creates the .so libraries, correct? I did find that missing binary that setup.py is looking for in the package installed through Armbian:

python3-opencv: /usr/lib/python3/dist-packages/cv2.cpython-36m-aarch64-linux-gnu.so

Also, installing the libqt4-dev package allows the build to work.

skvark commented 4 years ago

Yes, the build generates single statically linked binary which ends on Linux with .so.

That python3-opencv: /usr/lib/python3/dist-packages/cv2.cpython-36m-aarch64-linux-gnu.so is the OpenCV version which you have installed via your system package manager (apt-get or similar). That's completely different binary. The binaries created with the toolchain in this repository end up in cv2 subfolder under dist-packages after you install the generated wheel file.