-
Notifications
You must be signed in to change notification settings - Fork 318
Invalid Mex file. #58
Comments
Did you reboot the machine after you added the path? |
Yes, I did. I was just reading through others, and I feel like I'm missing something.
I don't have the |
Just to check, run |
Found it. I opened it with a notepad. I'm not sure how to remove @echo off
rem MSSDK71OPTS.BAT
rem
rem Compile and link options used for building MEX-files
rem using the Microsoft Windows Software Development Kit.
rem
rem $Revision: 1.1.6.2 $ $Date: 2011/03/09 05:35:27 $
rem Copyright 2010 The MathWorks, Inc.
rem
rem StorageVersion: 1.0
rem C++keyFileName: MSSDK71OPTS.BAT
rem C++keyName: Microsoft SDK
rem C++keyManufacturer: Microsoft
rem C++keyVersion: 7.1
rem C++keyLanguage: C++
rem
rem ********************************************************************
rem General parameters
rem ********************************************************************
set MATLAB=%MATLAB%
set VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 10.0
set VCINSTALLDIR=%VSINSTALLDIR%\VC
rem In this case, LINKERDIR is being used to specify the location of the SDK
set LINKERDIR=C:\Program Files\Microsoft SDKs\Windows\v7.1\
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;%LINKERDIR%\include;%LINKERDIR%\include\gl;%VCINSTALLDIR%\ATLMFC\INCLUDE;%INCLUDE%
set LIB=%VCINSTALLDIR%\LIB\amd64;%LINKERDIR%\LIB\X64;%VCINSTALLDIR%\ATLMFC\LIB\AMD64;%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" |
Recently there was a change in |
okay, well that help to clean it. But I'm still getting an invalid mex file. I reboot and did everything again, still doesn't work. |
@ramin0711: Also you might wanna use a tool like Dependency Walker on the MEX-files to confirm that all the dependencies are present on the path. btw, double check that you added |
I double checked the path, I have the bin. I'm not sure how to use the Dependency Walker to check Mex-files. Here's the first two lines,
|
Sorry but i must ask again if you are sure about the Plus what exactly is the error message? If its something like:
it usually means a missing DLL file in your system path (OpenCV DLLs in this case) To use "dependeny walker", just download the tool, run it, and open one of the compiled MEX-files |
Gotcha, I forgot to add the bin here, but I did add it to system path. the error I'm getting is this,
When I want to do the |
I redid everything again, matlab crashes every time I run my code |
ok then, that error message doesn't look like a compilation or PATH issue.. It appears to be originating from this line I'm guessing you are running the |
I have the xml file in the same folder, it was complaining about the mex function, now it just crash. Do I have to change D_SECURE_SCL=0 to one or just leave it? Any suspicions on why it crashes? |
It shouldn't be necessary for you to manually change the Now I'm not sure why MATLAB crashes, but it should create a dump/log file after any crash (possibly in the Other than that, I really don't know what's wrong in your case :) |
Here's the thing, I change the _SECURE_SCL to 1, and matlab crashed, I turn it back to what it was and |
Can you post the output of the following?
|
Sure, it's
|
Umm, that looks normal. Did you try any other function than |
Okay, I used im = imread('C34.jpg');
gr = cv.cvtColor(im, 'RGB2GRAY'); and here is the error. In order to get it to crash, I have to change it
|
I try this one as well, camera = cv.VideoCapture();
pause(2); The camera turn on with no error. |
@ramin0711 : I just submitted a PR that was merged. Retrieve the latest changes, recompile, and run |
Okay, I replace the mexopencv folder with the updated version on the web ( is that what you wanted me to do?), so I did everything again, and here's the result to
|
@kyamagu: ok, so it is as expected; When OpenCV was compiled Therefore mexopencv should be compiled with @ramin0711:
|
Yes, _SECURE_SCL should be set to 1 by default. And, indeed the following error looks like unmatched _SECURE_SCL flag.
@ramin0711 If you ever changed _SECURE_SCL in the mexopencv.make file, return it back to 1. And please post the crash report. |
Yes, by default VS2010 has the _SECURE_SCL set to 1. That's why we add |
@kyamagu: VS2010
VS2008
So since this flag is undefined in both opencv debug/release builds of VS2010, and since mexopencv links against the release builds, we should NOT set it to 1... In my configuration, I never touched the default |
@kyamagu I didn't change @amroamroamro here's the result
|
@amro That's interesting. I can't confirm this yet since I need to Kota |
@kyamagu The correct way to override it is by issuing:
To make things worse, i think that this is no longer necessary for VS2010 onwards (since release mode defaults to a value of 1). And it only should be considered for prior VS versions. If you want, I will make the necessary changes and submit a pull-request. I will update both README file and make.m |
@amro Thanks, yes please send me a pull request. |
@kyamagu: done. sorry this took me longer than I though... |
What did you change exactly? |
@ramin0711: I fixed the whole In the mean time, undo any changes you made to
|
@amroamroamro I appreciate! @ramin0711 If you think you messed up the |
@amroamroamro Thanks amro, it's working now. Although, one problem I have is that whenever I run one of the matlab files it works fine the first time, but crashes the second time. Thanks for taking the time to help me out. |
@ramin0711: i don't know, hard to say without debugging it.. Can you post the crash report, MATLAB should create files named like |
It's not big deal, I can live with it. It seems like when I use the camera, if I want to I run the code again, I have to delete the camera from variable list manually, if I use clear all or anything else matlab crashes, I don't know if there's any other easier way to fix the problem. I can send you the crash report, but it's like 12 mb and I can't open the file, how would you like me to send it? |
@ramin0711: sorry for the late reply. Are you still experiencing crashes with this? If so you should look for the text crash report (dont need the binary dump file).. |
I have the same problem, matlab crashes the second time I run the program. I am using mexopencv in Ubuntu 12.04 with Opencv 2.4.1. Here is the matlab crash dump file:
Please help me with this big problem because i am using it for my license project and i need it to work not just one time. Thank you! |
@lidiadunareanu Your issue is not the same. See this to fix. |
Thank you. --- On Wed, 5/22/13, Kota Yamaguchi notifications@github.com wrote: From: Kota Yamaguchi notifications@github.com @lidiadunareanu Your issue is not the same. See this to fix. — |
I saw a lot of people had a similar issue, didn't help me though. I'm running a Matlab R2012a 64 bit on a 64 bit windows, with sdk 7.1 and VS10. I added the system path,
C:\opencv\build\x64\vc10
I downloaded the mexopencv from the website, they talk about making something from opencv, but I'm not sure what they're talking about. All I did, downloaded opencv and mexopencv, run
make.mexopencv
on matlab. It seems okay, but when I try using one of the functions it doesn't work. what steps am I missing?Thanks
The text was updated successfully, but these errors were encountered: