32 bit mex with 32 bit MATLAB on Windows 7 64 bit OS failure to run

1 view (last 30 days)
I have a 32 bit mex that worked properly with R2011a (32bit) on Windows XP, but when I installed R2011a (32bit) on Windows 7 64 bit I get the following error message:
??? Invalid MEX-file 'C:\code\myfunction.mexw32': The specified module could not be found.
I was under the impression that R2011a 32 bit is supported on Windows 7 64 bit OS. What is going wrong here?

Answers (3)

Jan
Jan on 17 May 2011
Did you install the 32-bit runtimes of the used compiler?
EDITED: I got this message when I tried to run MEXW32 file compiled with MSVC or OWC, but forgot to install the runtime libs also. You can use the DependencyWalker to find the needed libs. See Kaustubha's answer.

Jason Ross
Jason Ross on 17 May 2011
Make sure your 32-bit and 64-bit houses are in order, as they are likely not arranged how you expect them to be. On 64-bit Windows, the 64-bit things are kept in "System32" and the 32-bit things are kept in "SysWow64". In a 32-bit command shell, what shows up as "System32" is actually "SysWow64". For example, perform the following steps:
Start a command shell (as Administrator if you have UAC on). Change into the C:\Windows\System32 directory and make a file:
echo "hello 64 bit" > hello64.txt
Now look with Windows Explorer and you will see this file where you expect it to be ... in C:\Windows\System32.
Now start the 32-bit environment by running C:\Windows\SysWow64\cmd.exe. Change directory to C:\Windows\system32 in this shell and create a similar file:
echo "hello 32 bit" > hello32.txt
Now look with the Explorer in C:\Windows\System32. You won't find the "hello32.txt" file there, but you will find it in C:\Windows\SysWow64.
So if you have things that are operating in a 32-bit environment on a 64-bit Windows host, you need to ensure that they are visible in the 32-bit environment.
So I bet if you have the other things sorted out (path, compiler settings, etc) if you put the dll's in C:\windows\syswow64 you will be able to find them.

Kaustubha Govind
Kaustubha Govind on 17 May 2011
It seems like you may not have all the DLLs required by the MEX-function on the path. See Solution# 1-X8A09.
  3 Comments
Kaustubha Govind
Kaustubha Govind on 17 May 2011
I expect that your configuration should work - you shouldn't have to recompile your libraries. Have you tried using Dependency Walker to make sure that you are not missing any libraries?
Gautam Vallabha
Gautam Vallabha on 19 May 2011
"Should this work if the DLLs are compiled this way?"
Jonathan: To reiterate what Jan and Kaustubha are saying, this is not guaranteed to work. If the mex file was compiled with, say Microsoft Visual C++ 2010, then the generated DLL will require the MS Visual C++ 2010 runtime library (which is a special DLL). If you copy the mex file to a new system, then you will get an error when you try to use it if the new system doesn't have the DLL, even if the original and new systems are both 32-bit.
In the above scenario, the workaround is to download & install the appropriate runtime library (aka. "Microsoft Visual C++ 2010 Redistributable Package"). This is relatively painless and quick once you identify which runtime library you need, and DependencyWalker will tell you this information.

Sign in to comment.

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!