How to make prototype files accessible to the MCR in C++?
Show older comments
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
More Answers (0)
Categories
Find more on C Shared Library Integration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!