Why do I receive an 'Invalid MEX file' error when deploying MATLAB code that utilizes the Haver datafeed?

1 view (last 30 days)
I have MATLAB code that uses the Haver datafeed using the Datafeed toolbox, in 32-bit MATLAB R2012a. I compiled this code into a standalone executable using MATLAB Compiler. However, when I try to run the executable on the target machine, I get the following error:
Invalid MEX-file
'C:\Users\QUANTA~1\AppData\Local\Temp\2\quantadmin\mcrCache7.17\Haver_1\toolbox\datafeed\datafeed\haverdatafeed.mexw32':
The specified module could not be found.
Error in
C:\Users\QUANTA~1\AppData\Local\Temp\2\quantadmin\mcrCache7.17\Haver_1\toolbox\datafeed\datafeed\@haver\haver.p>haver
(line 31)
Error in HaverData (line 149)
MATLAB:invalidMEXFile
How can I make this work?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 16 May 2012
Using the Haver datafeed requires the shared library called DLXAPI32.dll (for 32-bit version), provided by Haver. The MathWorks file haverdatafeed.mexw32 calls this DLL so this is most likely what is missing (although other possibilities exist, use Process Monitor by Microsoft Sysinternals if confirmation is necessary). You should have it either on your development machine, or should be able to download it from Haver's site.
Once you obtain the DLL, follow the steps below:
1. Put the DLL into your current workspace folder along with your MATLAB code.
2. Include it as an additional file before compiling (by dragging and dropping into the additional files pane in DEPLOYTOOL or using the -a option with MCC).
3. Include the following MATLAB code at the start of your deployed MATLAB code, so that your code sets up the proper paths to access the DLL during runtime:
%obtain path data
pathOld = getenv('PATH');
ctfPath = ctfroot;
appName = 'YourApplicationName';
%construct and set new path
pathNew = [pathOld ';' ctfPath '\' appName];
setenv('PATH', pathNew);
What the above code does is add the location where the DLL is stored in the CTF archive to the system PATH environment, so that calls to the DLL by the MEX file can find it. Please remember to change the 'YourApplicationName' string into the appropriate name.
3. Recompile your application and test on target machine.

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products


Release

R2012a

Community Treasure Hunt

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

Start Hunting!