0

I have been following the steps in this link: https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows

I am currently using Qt 5.10 with latest OpenCV 3.4.0. I also have Python 3.6.3 installed.

I have meet some errors at steps mingw32-make -j 4.

This is the error I copied from Command Prompt:

[100%] Linking CXX shared module ..\..\lib\python3\cv2.cp36-win_amd64.pyd
C:/Users/user/AppData/Local/Programs/Python/Python36/libs/libpython36.a: error adding symbols: File format not recognized
collect2.exe: error: ld returned 1 exit status
modules\python3\CMakeFiles\opencv_python3.dir\build.make:114: recipe for target 'lib/python3/cv2.cp36-win_amd64.pyd' failed
mingw32-make[2]: *** [lib/python3/cv2.cp36-win_amd64.pyd] Error 1
CMakeFiles\Makefile2:4081: recipe for target 'modules/python3/CMakeFiles/opencv_python3.dir/all' failed
mingw32-make[1]: *** [modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2
Makefile:161: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

Can someone explained to me what error am I facing and how do I solve this problem? Is there some file that I am missing?

I tried to google search the error but didnt get any good explanation or solution to this problem.

Sorry for my bad English and thanks in advance.

Edit: I found this link: https://pypi.python.org/pypi/opencv-python where it has cp36-win_amd64.pyd that are available to download. But I did change any thing in the file yet as I am unsure what is the error that I am currently facing.

Edit2: I found out that in this link: https://github.com/opencv/opencv_contrib/issues/971, there is someone having the same problem as mine. Haven't solve the problem yet but looking into it.

Edit3: I have tried the steps with Python 3.6.4. Also have the same issues. This is the CMakeList.txt for OpenCV Python part. Here's the whole CMakeList.txt : https://github.com/opencv/opencv/blob/master/CMakeLists.txt

if(BUILD_opencv_python3)
  status("")
  status("  Python 3:")
  status("    Interpreter:"     PYTHON3INTERP_FOUND  THEN "${PYTHON3_EXECUTABLE} (ver ${PYTHON3_VERSION_STRING})"       ELSE NO)
  if(PYTHON3LIBS_VERSION_STRING)
    status("    Libraries:"   HAVE_opencv_python3  THEN  "${PYTHON3_LIBRARIES} (ver ${PYTHON3LIBS_VERSION_STRING})"   ELSE NO)
  else()
    status("    Libraries:"   HAVE_opencv_python3  THEN  "${PYTHON3_LIBRARIES}"                                      ELSE NO)
  endif()
  status("    numpy:"         PYTHON3_NUMPY_INCLUDE_DIRS THEN "${PYTHON3_NUMPY_INCLUDE_DIRS} (ver ${PYTHON3_NUMPY_VERSION})" ELSE "NO (Python3 wrappers can not be generated)")
  status("    packages path:" PYTHON3_EXECUTABLE         THEN "${PYTHON3_PACKAGES_PATH}"                                    ELSE "-")
endif()

status("")
status("  Python (for build):"  PYTHON_DEFAULT_AVAILABLE THEN "${PYTHON_DEFAULT_EXECUTABLE}" ELSE NO)
if(PYLINT_FOUND AND PYLINT_EXECUTABLE)
  status("    Pylint:"  PYLINT_FOUND THEN "${PYLINT_EXECUTABLE} (ver: ${PYLINT_VERSION}, checks: ${PYLINT_TOTAL_TARGETS})" ELSE NO)
endif()

2 Answers2

0

This is a linking error. You should tell QMake (Or CMake) where to look for the library files (in your case OpenCV). You can take a look at the following links: QMake CMake

Also check the installation paths of both Python and OpenCV.

Reza
  • 3,473
  • 4
  • 35
  • 54
  • I think my Python and OpenCV paths doesn't has any problem considering that I am able to use both of these two in different application. I will look into both of the link you provide. Thanks for the reply. – Syntechies Feb 17 '18 at 18:10
  • @Syntechies you can get a better help if you put your CMake file (CMakeLists.txt) here – Reza Feb 17 '18 at 22:09
  • May I know which CMakeLists.txt I should be looking at? There are several CMakeLists.txt exists. – Syntechies Feb 18 '18 at 06:59
  • @Syntechies Your program's CMake file. The one that you are using to compile your program. The best way to solve your problem is that you should create a very simple program that use your libraries and then try to compile and link it. Please put your program and your CMake file here to find your solution. Without those files anything would be just a guess! – Reza Feb 18 '18 at 11:17
  • I have insert the OpenCV Python part in CMake on the Edit3, although I am not sure if this CMakeLists.txt is the correct one. There are several CMake file exists in OpenCV. – Syntechies Feb 18 '18 at 11:36
0

Try to uncheck this option from cmake: BUILD_opencv_python_bindings_generator Before click generate