Creating EXE with DLL attached

Let say i have 2 m files:
%%% first m file
.m
function mainapp
global a b c
a=5;
dllfile
c=a+b;
figure(1)
text(0.5,0.5,num2str(c));
%%% second m file
dllfile.m
function dllfile
global a b c
b=4;
%%%
My question is how do i create mainapp.exe and dllfile.dll so they are functional when i start mainapp.exe from windows?
Also, if this above is possible, am i going to be able to change for example only dll file (compile newer version which does, for example b=3 instead of b=4) and continue to use mainapp.exe?
Thank you in advance
I have Windows 7 32bit
Matlab 2008b
Microsoft Visual Studio 2008

 Respuesta aceptada

Titus Edelhofer
Titus Edelhofer el 15 de Abr. de 2012

0 votos

Hi,
compiling dllfile.m into a dllfile.dll is possible with compiler, but you will not be able to call this dll from mainapp.m (and also not from mainapp.exe). This .dll can only be called from some non-MATLAB environment (e.g. C/C++). So: unfortunately you will not be able to have something like a "plugin" concept here. You can only compile both files into one .exe by
mcc -m mainapp.m
It will compile both files. Whenever dllfile.m changes, you have to recompile ...
Titus

3 comentarios

Walter Roberson
Walter Roberson el 15 de Abr. de 2012
Titus, wouldn't it be possible to call the DLL by using loadlibrary() ?
Friedrich
Friedrich el 16 de Abr. de 2012
One can't use a MATLAB Compiler generated DLL (or other component) back in MATLAB. However, when he creates a C/C++ main which calls the generated DLL, than he can use the OS based loadlibrary command to call the DLL.
Titus Edelhofer
Titus Edelhofer el 16 de Abr. de 2012
That's right. This way the DLL and the mainapp.exe don't share the MCR and therefore can "coexist" ...

Iniciar sesión para comentar.

Más respuestas (1)

Drago Zarkovic
Drago Zarkovic el 16 de Abr. de 2012

0 votos

I guess it makes some sense... Suppose somebody could test and know work of your DLL file, if it will be accessible by matlab's EXE, or matlab...
So if you want "plugin" concept, you will need some work in Microsoft Visual?
Yes I know i can done it by
mcc -m mainapp.m dllfile.m
Thank you very much Titus for your answer

Categorías

Más información sobre C Shared Library Integration en Centro de ayuda y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by