How to make prototype files accessible to the MCR in C++?

Hello,
I'm trying to use a MATLAB compiled C++ DLL in my C++ application. I've written a function that appears to run just fine in MATLAB. I attempt to use the same DLL in my application and it reports the error below as a mwException.
Previously accessible file "E:\HP_WORK\Matlab-Panther-Integration-Research\OpenAccesssMATLAB\oa_matlab.m" is now inaccessible.
----
I don't understand why the file is accessible in MATLAB and not in my code.
The file, oa_matlab.m, is a prototype file that the MCR directed me to create as it will not allow the use of my header file directly i.e. it throws a mwException otherwise.
How do I make oa_matlab.m accessible in my C++ code?
----
Here is my MATLAB function. Note the call to 'cd' is an act of desparation...I would like to point MATLAB to my prototype file somehow.
MATLAB R(2012a)
function m = magicsquare_panther(n)
if ischar(n) n = str2num(n); end
m = magic(n);
prototype_path='E:\HP_WORK\Matlab-Panther-Integration-Research\OpenAccesssMATLAB'; addpath('E:\HP_WORK\Panther_Checkouts\OpenAccess_rev2307\Debug','e:\HP_WORK\Panther_Checkouts\OpenAccess_rev2307\CommonFiles',prototype_path) cd(prototype_path) loadlibrary('CommonFiles.dll',@oa_matlab) %loadlibrary('CommonFiles.dll','OpenAcessMATLAB.h')
s='Hello From MATLAB land'; s(end + 1)=0; % oa_displayStatus calllib('CommonFiles','oa_displayStatus',s); unloadlibrary CommonFiles

 Accepted Answer

I've learned how to do this correctly.
After you create a prototype file you must add it to the list of files to be "compiled" into your MATLAB generated dll. After completing this step everything will work as expected and you can call functions from external C++ libraries in your MATLAB generated dll.

More Answers (0)

Categories

Asked:

on 17 Aug 2012

Community Treasure Hunt

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

Start Hunting!