build opencv for windows

asked 2018-12-07 12:24:05 -0500

trispade gravatar image

updated 2018-12-07 21:02:53 -0500

Hey I am trying to build OpenCV 4.0 for Windows 10 with Python bindings and then use them with my anaconda environment. Unfortunately after I build everything and then try to do a "pip install (path to install folder)\python" it seems like it installed correctly but I get a recursion error similar to the recursion post I've provided below. I have also attempted to just copy the pyd and DLLs as suggested but I get an import error DLL couldn't be found. I have even tried to building with SHARED LIBS off and then copying and pasting that with and without DLLs and I still get the DLL couldn't be found error. Has anyone got this successfully built for windows 10 and an Anaconda env running python 3.7.1? if So can you help me figure it out.

link to recursion post

link to a post with static lib build


I came across this post and decided to give some of it a try and dumpbin.exe may have shed some more light on my situation when it comes to copy and pasting. I rebuilt my 4.0 source and used static libraries this time. I am also missing several of these dlls in my anaconda paths. I guess I need to manually grab some of these like the libgst*.dll DLLs. I'm not to sure if I need to grab what appear to be system dlls though. However since I am building static libraries now I think I only need to worry about the external DLLs.

dumpbin.exe C:\OpenCV\build\opencv-4.0.0\install\python\cv2\python-3.7\cv2.cp37-win_amd64.pyd /IMPORTS | findstr dll python37.dll libgstpbutils-1.0-0.dll libgstreamer-1.0-0.dll libgstriff-1.0-0.dll libglib-2.0-0.dll libgstapp-1.0-0.dll libgobject-2.0-0.dll GDI32.dll ole32.dll KERNEL32.dll USER32.dll OLEAUT32.dll COMDLG32.dll ADVAPI32.dll MF.dll MFReadWrite.dll d3d11.dll api-ms-win-downlevel-shlwapi-l1-1-0.dll

edit retag flag offensive close merge delete


import DLL error, can you run an exe (c++ sample compiled)? .

LBerger gravatar imageLBerger ( 2018-12-07 13:40:23 -0500 )edit

I haven't tried yet I will give it a whirl tomorrow.

trispade gravatar imagetrispade ( 2018-12-07 21:03:18 -0500 )edit

You can use dependency walker with file cv2.pyd : open cv2.pyd and wait (may be 5 minutes...) and it will give you missing dll

LBerger gravatar imageLBerger ( 2018-12-08 02:33:48 -0500 )edit

yeah it looks like its not seeing my gstreamer DLLs: these are the ones its missing

  • libgstpbutils-1.0-0.dll libgstreamer-1.0-0.dll libgstriff-1.0-0.dll libglib-2.0-0.dll libgstapp-1.0-0.dll libgobject-2.0-0.dll

I added these into the anaconda environment and loaded the cv2.pyd with dependency walker and now im not seeing anything missing. However I am still getting the import error.

trispade gravatar imagetrispade ( 2018-12-08 04:29:49 -0500 )edit

can you run an opencv sample in opencv bin I think you can find opencv_waldboost_detector.exe

LBerger gravatar imageLBerger ( 2018-12-08 04:40:24 -0500 )edit

I don't see opencv_waldboost_detector.exe but I do have variouse opencv_test_*.exe files where * is different names. So far they seem to be running with no issue.

trispade gravatar imagetrispade ( 2018-12-08 17:04:37 -0500 )edit

So I moved some DLLs around and it looks like the Gstreamer DLLs are now being found. It looks like I'm having an issue with the API-MS-WIN-.DLL, EXT-MS-WIN-.DLL, and one IESHIMS.DLL libraries.

trispade gravatar imagetrispade ( 2018-12-08 17:20:02 -0500 )edit

" API-MS-WIN-.DLL, EXT-MS-WIN-.DLL, and one IESHIMS.DLL libraries." that's not a problem. Can you run opencv_waldboost_detector.exe?

LBerger gravatar imageLBerger ( 2018-12-09 02:48:17 -0500 )edit

I don't have opencv_waldboost_detector.exe is it something I have to choose to build?

trispade gravatar imagetrispade ( 2018-12-09 07:29:48 -0500 )edit

in build directory search exe file. If you don't find an exe file you must rebuild with build_samples ON

LBerger gravatar imageLBerger ( 2018-12-09 10:48:55 -0500 )edit