I have compiled Mex file successfully on my laptop. But when I am running it, it says Invalid mex file \'c:\\newfolder\\filename.mexw32\' The specified module could no
I had this problem also when upgrading from Matlab2010a/VS2008 to Matlab2013a/VS2010.
All my environment variables were sent correctly. A reboot fixed problems with OpenCV dlls not being found, I assume that it was still trying to link to the OpenCV dlls for VS2008 (even though I had changed the path). However still my mex file could not find libmex.dll.
When I installed Matlab2013a, I did not uninstall the old version (in case I wanted to go back). However that was the cause of my problem. Once I uninstalled the old version of Matlab and rebooted again, the problem was gone.