Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

win8 Pro+ matlab2013a+VS2012( or VS2010) : Invalid MEX-file, ..., specified module could not be found #104

Closed
yreme opened this issue Mar 3, 2014 · 6 comments

Comments

@yreme
Copy link

yreme commented Mar 3, 2014

Hi, I came across an issue :

    Invalid MEX-file, ..., specified module could not be found 

similiar with #58 , #76

opencv run well in VS, but meet trouble in matlab

My OS environment is win8 Pro x64 + matlab2013a, I have try those

  1. mex -setup with VS2012 or VS2010 , and '/D_SECURE_SCL=0' or '/D_SECURE_SCL=1' in make.m , but helpless. My VS2012 could successfully run opencv2.4.8
    if isVS && (str2double(c.Version) < 10 || opts.debug)
        comp_flags{end+1} = '/D_SECURE_SCL=1';
        fprintf('[if] D_SECURE_SCL  %s\n','/D_SECURE_SCL=1');
        %VS2010 and newer: In debug mode, the default value for _SECURE_SCL is 1. In release mode, the default value for _SECURE_SCL is 0.
    else
        %comp_flags{end+1} = '/D_SECURE_SCL=1';
        fprintf('[else] D_SECURE_SCL  %s\n','/D_SECURE_SCL=0');
        %VS2010 In debug mode, the default value for SECURESCL is 1, .... In release mode, the default value for SECURESCL is 0.


        comp_flags{end+1} = '/D_SECURE_SCL=0';
    end
  1. It is noticable such problem also occurs at opencv's matlab modual in my PC. They could be complied, but error with :
      Invalid MEX-file, ..., specified module could not be found 

DLL with Dependency Walker

Besides, with Dependency Walker on the MEX-files (GaussianBlur mexfiles) , I found such dll are relatived,

API-MS-WIN-CORE-SYNCH-L1-1-0.DLL
SHCORE.DLL
SHLWAPI.DLL
EXT-MS-WIN-ADVAPI32-PSM-APP-L1-1-0.DLL
EXT-MS-WIN-NTUSER-MESSAGE-L1-1-0.DLL
IEFRAME.DLL

indeed most of those could be found in the path:

     windows/system32

It seems they are all right.

mexopts.bat files with VS2012

@echo off
rem MSVC110OPTS.BAT
rem
rem    Compile and link options used for building MEX-files
rem    using the Microsoft Visual C++ compiler version 11.0
rem
rem    $Revision: 1.1.6.1 $  $Date: 2012/09/25 18:20:24 $
rem    Copyright 2007-2012 The MathWorks, Inc.
rem
rem StorageVersion: 1.0
rem C++keyFileName: MSVC110OPTS.BAT
rem C++keyName: Microsoft Visual C++ 2012
rem C++keyManufacturer: Microsoft
rem C++keyVersion: 11.0
rem C++keyLanguage: C++
rem C++keyLinkerName: Microsoft Visual C++ 2012
rem C++keyLinkerVer: 11.0
rem
rem ********************************************************************
rem General parameters
rem ********************************************************************

set MATLAB=%MATLAB%
set VSINSTALLDIR=D:\ProgramFiles\VS2012
set VCINSTALLDIR=%VSINSTALLDIR%\VC
rem In this case, LINKERDIR is being used to specify the location of the SDK
set LINKERDIR=C:\Program Files (x86)\Windows Kits\8.0\
set PATH=%VCINSTALLDIR%\bin\amd64;%VCINSTALLDIR%\bin;%VCINSTALLDIR%\VCPackages;%VSINSTALLDIR%\Common7\IDE;%VSINSTALLDIR%\Common7\Tools;%LINKERDIR%\bin\x64;%LINKERDIR%\bin;%MATLAB_BIN%;%PATH%
set INCLUDE=%VCINSTALLDIR%\INCLUDE;%VCINSTALLDIR%\ATLMFC\INCLUDE;%LINKERDIR%\include\um;%LINKERDIR%\include\shared;%LINKERDIR%\include\winrt;%INCLUDE%
set LIB=%VCINSTALLDIR%\LIB\amd64;%VCINSTALLDIR%\ATLMFC\LIB\amd64;%LINKERDIR%\lib\win8\um\x64;%MATLAB%\extern\lib\win64;%LIB%
set MW_TARGET_ARCH=win64

rem ********************************************************************
rem Compiler parameters
rem ********************************************************************
set COMPILER=cl
set COMPFLAGS=/c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD
set OPTIMFLAGS=/O2 /Oy- /DNDEBUG
set DEBUGFLAGS=/Z7
set NAME_OBJECT=/Fo

rem ********************************************************************
rem Linker parameters
rem ********************************************************************
set LIBLOC=%MATLAB%\extern\lib\win64\microsoft
set LINKER=link
set LINKFLAGS=/dll /export:%ENTRYPOINT% /LIBPATH:"%LIBLOC%" libmx.lib libmex.lib libmat.lib /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /manifest /incremental:NO /implib:"%LIB_NAME%.x" /MAP:"%OUTDIR%%MEX_NAME%%MEX_EXT%.map"
set LINKOPTIMFLAGS=
set LINKDEBUGFLAGS=/debug /PDB:"%OUTDIR%%MEX_NAME%%MEX_EXT%.pdb"
set LINK_FILE=
set LINK_LIB=
set NAME_OUTPUT=/out:"%OUTDIR%%MEX_NAME%%MEX_EXT%"
set RSP_FILE_INDICATOR=@

rem ********************************************************************
rem Resource compiler parameters
rem ********************************************************************
set RC_COMPILER=rc /fo "%OUTDIR%mexversion.res"
set RC_LINKER=

set POSTLINK_CMDS=del "%LIB_NAME%.x" "%LIB_NAME%.exp"
set POSTLINK_CMDS1=mt -outputresource:"%OUTDIR%%MEX_NAME%%MEX_EXT%;2" -manifest "%OUTDIR%%MEX_NAME%%MEX_EXT%.manifest"
set POSTLINK_CMDS2=del "%OUTDIR%%MEX_NAME%%MEX_EXT%.manifest"
set POSTLINK_CMDS3=del "%OUTDIR%%MEX_NAME%%MEX_EXT%.map"
@kyamagu
Copy link
Owner

kyamagu commented Mar 3, 2014

Where do you install OpenCV? You have to set up a system PATH variable pointing to the correct OpenCV location. Check README.

@yreme
Copy link
Author

yreme commented Mar 3, 2014

my opencv dll path is:

D:\opensource\opencv\opencv2.4.8\opencv\build\x64\vc11\bin

so in the system path:

%opencv248%\x64\vc11\bin;%opencv248%\x64\vc10\bin;

where

opencv248=D:\opensource\opencv\opencv2.4.8\opencv\build

Is there any other solution that might concern windows 8?

@kyamagu
Copy link
Owner

kyamagu commented Mar 3, 2014

Are you sure your Matlab is 64-bit? Matlab for both 32-bit and 64-bit can be installed in win64 environment.

@yreme
Copy link
Author

yreme commented Mar 3, 2014

this matlab is 64bit. I install this matlab and mexopencv on another x64
win7 computer , it works. so I donot known what is the trouble in win8.

2014-3-3 ÏÂÎç10:20ÓÚ "Kota Yamaguchi" notifications@github.comдµÀ£º

Are you sure your Matlab is 64-bit? Matlab for both 32-bit and 64-bit can
be installed in win64 environment.

¡ª
Reply to this email directly or view it on GitHub.

@kyamagu
Copy link
Owner

kyamagu commented Mar 3, 2014

Then I don't know. It can be you're not rebooting the OS for a PATH to take effect. What I can tell is that the error message says that OpenCV dll's are not in the PATH. Check again any typos, etc.

@yreme
Copy link
Author

yreme commented Mar 4, 2014

Thanks, your are all right! The problem was solved by directly adding opencv dll path

D:\opensource\opencv\opencv2.4.8\opencv\build\x64\vc11\bin

rather than set user variable opencv248=D:\opensource\opencv\opencv2.4.8\opencv\build .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants