opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.42k stars 5.76k forks source link

Trouble generating Matlab bindings; CMake complains of Matlab 32bit use when installed Matlab is 64bit #1551

Open SID311 opened 6 years ago

SID311 commented 6 years ago

I'm trying to install the new OpenCV source files on Windows along with the latest opencv_contribute using CMake but keep running into this error:

CMake Warning at C:/OpenCV/opencv_contrib-master/modules/matlab/CMakeLists.txt:77 (message): Your compiler is 64-bit but your version of Matlab is 32-bit. To build Matlab bindings, please switch to a 32-bit compiler. Call Stack (most recent call first): C:/OpenCV/opencv_contrib-master/modules/matlab/CMakeLists.txt:90 (warn_mixed_precision)

However, I know I am using a 64-bit version of Matlab, says so in the 'About Matlab' dialog box.

System information (version)
Detailed description
Steps to reproduce

Cleanly reinstalled above mentioned software. Using the following Matlab paths:

MATLABBIN C:/Program Files/MATLAB/R2017b/bin/matlab.exe MATLAB_INCLUDEDIRS C:/Program Files/MATLAB/R2017b/extern/include MATLAB_LIBMAT C:/Program Files/MATLAB/R2017b/bin/win64/libmx.dll MATLAB_LIBMEX C:/Program Files/MATLAB/R2017b/bin/win64/libmex.dll MATLAB_LIBMX C:/Program Files/MATLAB/R2017b/bin/win64/libmx.dll MATLAB_MEXEXTSCRIPT C:/Program Files/MATLAB/R2017b/bin/mexext.bat MATLAB_MEXSCRIPT C:/Program Files/MATLAB/R2017b/bin/mex.bat MATLAB_ROOTDIR C:/Program Files/MATLAB/R2017b/bin/matlab.exe

I had to manually find the paths for the libmat, libmex, and libmx DLLs, but the rest were found by CMake. Not sure if those are correct.

SID311 commented 6 years ago

There error seems to come from the way the Cmake file ''OpenCVFindMatlab.cmake' tries to determine the Matlab architecture.

Details here.

saskatchewancatch commented 6 years ago

I know in MATLAB version 2015a there is a problem with the mexext.bat Windows batch file in $MATLAB_ROOT/bin that causes it to not report the proper architecture if your installation path has spaces. I see from the debug info you provided that you installed somewhere into "Program Files" which contains a space. This is because their script gets thrown off because the writers did not double-quote a shell path expansion, confounding their batch script conditionals, causing "Unsupported Architecture" to be reported instead. Possibly this is causing your issues.

You mentioned: "I had to manually find the paths for the libmat, libmex, and libmx DLLs". Observe that the paths for these entries have win64 in them. This suggests to me that you may have the faulty version of mexext.bat. If you look at the output of CMake's Configure step, you may just see the output from mexext.bat that reports "Unsupported architecture".

And taking another stab at things, you may even be able to set MATLAB_ARCH manually inside OpenCVFindMatlab.cmake to win64 after where it tries to check.

And yet another stab at things, are you sure you don't have a win32 folder somewhere in your MATLAB_ROOT/bin?

I hope this helps.