can't find Matlab coder generated mexFunction

Hello,
I used Matlab Coder to generate a randn mexFunction and used it in another mexFunction. The code runs perfectly well on two computers but not on the third one. Matlab said can't find randn1.mexw64.
What could have happened?
Thanks.

Answers (2)

Hi,
perhaps the third computer is a 32bit MATLAB/Windows? Just enter
mexext
in the 3rd computer. If it returns mexw32, you have to generate and compile the code on the 3rd computer again ...
Titus

11 Comments

I don'T have the computer with me now so I can't test on it. I'll try this once I get to use the computer.
However, Matlab coder was installed in another 64-bit Computer/Matlab. Can I generate randn1.mexw32 with this Matlab Coder that i have?
I'm not sure, I guess no. What you definetely can do is to install the 32Bit MATLAB in parallel to your 64Bit MATLAB and generate the randn1.mexw32 there.
How can I install a 32bit Matlab in parellel to the 64bit? The Matlab Coder came with the 64bit Matlab. Can I use it to generate a mexw32 in another 32bit Matlab?
Jane: Please look at these instructions for installing 32-bit MATLAB on a 64-bit machine. I think you need to simply activate the 32-bit version also with the same license number as the 64-bit version to get access to MATLAB Coder on it. I would recommend contacting MathWorks Installation/Licensing Support if you run into issues.
Hi Jane,
installing the 32 bit version you don't run the setup.exe in the top folder but run the setup.exe in the win32 folder...
Titus
I've given it another thought and realized that the Matlab should not be a 32bit one. I have an m-script which runs A.mexw63 and B.mexw64. The randn1.mexw64 is used in B.mexw64 but not in A.mexw64.
When running the m-script, A.mexw64 was successful but not B.mexw64 and the error was in B.mexw64 because Matlab couldn't find the rand1.mexw64 file.
What could be the possible cause?
PS: I'm sorry that I have to debug the error without having the 3rd computer within reach. It is a colleague's laptop and I only have very limited time to work on it. But the final code must run on this laptop as he is the one who is going to do the final presentation to the clients.
Thanks.
Hi Jane,
those files are all in the same folder, so it's not a path issue? Then my ideas slowly fade out ... sorry. And I guess the laptop has the same version/release of MATLAB running?
Titus
The Matlab version in which Coder is incorporated is R2011b and the 2nd computer on which the generated mexFunction worked is also a R2011b. However, the generated mexFunction does not work on the R2011a laptop. I have tried to run just the Coder-generated mexFunction with the laptop and the same error appeared: Invalid MEX-file...: das angegebene Modul wurde nicht gefunden (which means the module was not found)
Jane: The "module not found" type error is typically thrown if the MEX file depends on other DLLs that could not be found on the machine where it is being run. Assuming that you don't load other DLLs from your MEX-file, my best guess is that you used Visual Studio to generate the MEX-file and that you don't have the corresponding Visual C++ redistributables installed on the target laptop. See this solution for more information: http://www.mathworks.com/support/solutions/en/data/1-94SRDF/index.html (Be sure to get the redistributables for the version of Visual Studio that you used with MATLAB Coder)
Thanks for the reply. Unfortunately the module which was not found was generated with Matlab Coder. I did not at all use Visual C++ to write this mexFunction. It is just the normal Matlab randn function generated by Coder.
It is true that other DLLs on which the mexFunction depends are not found. I used dependencywalker.exe to check it. The missing DLLs are libmx.dll, libmex.dll, libemlrt.dll and libmwmathutil.dll.
What can I do to make this mexFunction find these files ?

Sign in to comment.

I have read somewhere that a possible solution is to use dependencywalker to check the required files needed to run the mexFunction.
I have tried that and here are the missing files: libmx.dll libmex.dll libemlrt.dll libmwmathutil.dll
What should I do to make the mexFunction find these missing .dll files?
Thanks.

4 Comments

Those libraries ship with MATLAB and should be in $matlabroot/bin/win64. Are you using a different version of MATLAB on the laptop?
Regarding your previous comment, MATLAB Coder uses Visual Studio (or whatever compiler was selected using "mex -setup") in the back-end to compile the MEX binary from C code that it generated.
Are you sure that Dependency Walker doesn't also point to any MSVC libraries missing?
I encounter the same problem: the mex file cannot run with error:invalid mex-file the specified module could not be found.
dependencywalker shows the only missing files are those dlls.
After I add bin/win64 folder to systen path and relaunch the dependencywalker, now the Mathwork dlls got resolved, and further walking reveals new missing dlls.
API-MS-WIN-CORE-KERNEL32-PRIVATE-L1-1-1.DLL
API-MS-WIN-CORE-PRIVATEPROFILE-L1-1-1.DLL
API-MS-WIN-CORE-SHUTDOWN-L1-1-1.DLL
API-MS-WIN-SERVICE-PRIVATE-L1-1-1.DLL
Error: At least one required implicit or forwarded dependency was not found.
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
But the dlls exsit in my PC:
C:\Windows\System32\downlevel\API-MS-Win-Core-Kernel32-Private-L1-1-1.dll
C:\Windows\SysWOW64\downlevel\API-MS-Win-Core-Kernel32-Private-L1-1-1.dll
C:\Windows\WinSxS\amd64_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_6.3.9600.16384_none_2c5177c069a919dd\API-MS-Win-Core-Kernel32-Private-L1-1-1.dll
C:\Windows\WinSxS\x86_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_6.3.9600.16384_none_d032dc3cb14ba8a7\API-MS-Win-Core-Kernel32-Private-L1-1-1.dll
C:\Users\rmd\AppData\Local\GeoGebra_6\app-6.0.583\API-MS-Win-Core-Kernel32-Private-L1-1-1.dll
-----
C:\Windows\System32\downlevel\api-ms-win-core-privateprofile-l1-1-1.dll
C:\Windows\SysWOW64\downlevel\api-ms-win-core-privateprofile-l1-1-1.dll
C:\Windows\WinSxS\amd64_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_6.3.9600.16384_none_2c5177c069a919dd\api-ms-win-core-privateprofile-l1-1-1.dll
C:\Windows\WinSxS\x86_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_6.3.9600.16384_none_d032dc3cb14ba8a7\api-ms-win-core-privateprofile-l1-1-1.dll
C:\Users\rmd\AppData\Local\GeoGebra_6\app-6.0.583\api-ms-win-core-privateprofile-l1-1-1.dll
-----this one may be missing, I will copy it and have a try
C:\Users\rmd\AppData\Local\GeoGebra_6\app-6.0.583\api-ms-win-core-shutdown-l1-1-1.dll
-----
C:\Users\rmd\AppData\Local\GeoGebra_6\app-6.0.583\api-ms-win-service-private-l1-1-1.dll
C:\Windows\System32\downlevel\api-ms-win-service-private-l1-1-1.dll
C:\Windows\SysWOW64\downlevel\api-ms-win-service-private-l1-1-1.dll
C:\Windows\WinSxS\amd64_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_6.3.9600.16384_none_b8233abb5511544f\api-ms-win-service-private-l1-1-1.dll
C:\Windows\WinSxS\x86_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_6.3.9600.16384_none_5c049f379cb3e319\api-ms-win-service-private-l1-1-1.dll

Sign in to comment.

Categories

Asked:

on 2 May 2012

Commented:

on 8 Nov 2024

Community Treasure Hunt

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

Start Hunting!