How can I create an executable file from function that need to "addpath" some folders and call one hundred functions and dll files?

14 views (last 30 days)
Hi all. I'm using a code that that need to setpath some foders and run properly in matlab, I create an executable file by mcc- m write_dfsu_2D.m, but when I open .exe file, it doesn't work. for more, there is an "if cluase" that isn't true when I run function, but is true when I run executable file and make an error:
if (exist(MatlabDMdll,'file') == 2)
elseif (exist(MatlabDMdllDev,'file') == 2)
debug = true;
MatlabDMdll = MatlabDMdllDev;
else
error(id('LibNotFoundDLL'),'Can not find dfsManager library dll (MatlabDM.dll)')
end
when the black window of executable file is opened, I face this probles:
??? Error using ==> dfsManager.dfsManager at 147
can not find the dfsManager library dll matlabDM.dll
Error in ==> write_dfsu_2D at 8
dfsManager:dfsManager:LibNotFoundDLL
I'm beginner and I have to use some examples of http://www.mikebydhi.com/Download/DocumentsAndTools/Tools/MATLABDFS2008.aspx but I don't know how can I create an executable file from this function. Could someone help me out please? Thanks in advance.

Accepted Answer

Friedrich
Friedrich on 10 May 2013
Edited: Friedrich on 10 May 2013
Hi,
start here:
and VERY important in the case you use laodlibrary:
You need to add the DLL, (in 64bit also the generated thunk library) as shared ressource and helper file (-a flag for the mcc call).
You don't need to worry about paths and folders. All folder you add to your exe are added to the MATLAB search path at startup of your exe. So no addpath or CD is needed.
  7 Comments
Friedrich
Friedrich on 21 May 2013
HI,
this part
"It is not possible to call a function in a MATLAB compiled dll using calllib. This is because a dll dependent on the mcr can not be loaded into MATLAB."
Means you can't use a MATLAB Compiler generated DLL back in MATLAB with loadlibrary and calllib.
However you don't have a MATLAB Compier generated DLL. So callib and loadlibray should work. So what does not work mean in detail? What error do you get when running which line of code?
In the case you wan't an alterated input file do NOT embed it into the CTF. At startup the MCR checks if the extracted CTF content changed, if so it reextracts the CTF which leads to overwriting the file and you get back the initial values. Its better to place an input file next to the exe and determine at runtime the path to it:
This will give the desired result.
Zahura
Zahura on 21 May 2013
That works fine, I so greatly appreciate, I will forever be beholden to you, I'd like to say thank you, For your helpful giving ways, I won't forget your kindness...

Sign in to comment.

More Answers (0)

Categories

Find more on C Shared Library Integration 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!