Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Adventures in OpenCV Building: OpenCV + Contrib 3.4 build results in neutered Java and Python files and no Matlab bindings

Hello All,

So I have been trying to successfully build OpenCV + Contrib 3.4 for about a week. My setup is as follows:

  • CMake 3.10.2 using Visual Studio 15 2017 Win64 (as seen in one of the screenshots above)
  • OpenCV 3.4.0 and OpenCV_Contribute 3.4.0 (assumed, latest build from GitHub)
  • Matlab 2017b, C++ compiler set as Microsoft Visual C++ 2017, Computer Vision System Toolbox OpenCV Interface installed (v
  • Python 3.6.4 64 bit w/ Numpy (ver 1.14.0)
  • Windows 10 Pro 64 bit 64 bit Windows 10 Pro 64 bit

I've set the following options, I can configure and generate without errors:

  • VTK 8.1.0
  • GStreamer 1.12.4 (Regular and Dev installed)
  • OpenNI2 (ver 2.2.0, build 33)
  • Intel TBB (ver 2018.0 interface 10001)
  • Intel IPP (ICV version): 2017.0.3 [2017.0.3] (I have the 2018.0 version, but don't know how to make CMake locate it.)
  • Intel MKL 2018.0
  • Apache Ant (ver 1.10.2)

I've spent the week building from vanilla and each subsequent extra, one by one. I only have trouble with open_matlab not being built because of errors:


Failed to compile CamShift: CamShift.cpp
CUSTOMBUILD : error C2065: 'type': undeclared identifier
CUSTOMBUILD : error C2664: 'cv::Mat::Mat(cv::Mat &&)': cannot convert argument 1 from
4>  '::size_t' to 'cv::Size'


Error   C2039   'type': is not a member of 'cv::DataType<Scalar>'
Error   C2065   'type': undeclared identifier   
Error   C2664   'cv::Mat::Mat(cv::Mat &&)': cannot convert argument 1 from

Everything else seems to build fine. I've built the ALL_BUILD project in both Debug and Release configurations and also the INSTALL soon after, also in both Debug and Release configurations.

On top of that, my Java files and Python files don't work:

My Java files: opencv-340.jar = 601kb, opencv_java340.dll = 2.2MB; while the ones from the official Windows pack are 403kb and 44.1MB, respectively.

My python file: cv2.cp36-win_amd64.pyd = 6.4MB, while the unofficial prebuilt Python libraries, opencv-python, comes in at 78.7MB.

Testing a small Java program in Eclipse, i get scolded with:

Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\OpenCV\build\install\java\x64\opencv_java340.dll: Can't find dependent libraries
    at java.base/java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.base/java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.base/java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.base/java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.base/java.lang.System.loadLibrary(Unknown Source)
    at opencv_helloworld.HelloCV.main(

And testing the Python library by importing cv2 with the Python interpreter from the command prompt greets me with:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.


Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: %1 is not a valid Win32 application.

Similarly, when starting a simple C++ program in Visual Studio, I get endless missing DLL complaints; first it wants to know where opencv_world.dll is, so I show it; then it will complain about missing gstreamer DLLs; from there its missing a tbb.dll, and on and on, like a little kid asking 'why?' endlessly.

However, after switching my crappy builds with professional ones, everything is fine.

I've followed countless "Install OpenCV with contrib/matlab/python/java" tutorials. None go into detail that might shine light on this problem for me. Most are outdated; some say you don't need the Debug builds, others say you just need to build the INSTALL project, and it should build everything in both the Debug and Release configurations. Which is correct?

I must be missing something embarrassingly basic, but what?


How do I build Matlab bindings correctly when Configuration and Generation in CMake so no problems?

Why do my Java and Python builds come out puny and dysfunctional?

What is the correct procedure to building OpenCV from source using Visual Studio 15 2017? Do I build the ALL_BUILD or just the INSTALL project?

Where are the DLLs/LIBs from third party modules, like GStreamer, supposed to end up? Why are there two bin folders: one in build\bin and the other in build\x64\vc15\bin? Where is everything supposed to go?

Thanks for any help.