Call MATLAB-created DLL
4 views (last 30 days)
Show older comments
Hi,
I'm trying to call a MATLAB created DLL-File in MATLAB but the result is not as expected. I found ot that I have to pass 4 arguments to adress the function but still something is wrong? Following code demonstrates the complete process:
%% Function File
% function OUTPUT = FlipMyString(INPUT)
% OUTPUT = fliplr(INPUT);
%% Call-Test of Function
OUTPUT = FlipMyString('TESTSTRING');
%% Create DLL
mcc -g -v -W cpplib:libFlipMyString -T link:lib FlipMyString
%% Call Library
LIBRARY = 'libFlipMyString';
if ~libisloaded(LIBRARY)
loadlibrary(LIBRARY)
end
LIB = libfunctions(LIBRARY);
[A,B,C] = calllib(LIBRARY,LIB{end},1,'teststring',1,'TESTSTRING')
%% Unload Library
unloadlibrary(LIBRARY)
0 Comments
Answers (1)
Nagarjuna Manchineni
on 7 Mar 2017
The library (.dll) created using MATLAB cannot be loaded into another MATLAB. A DLL generated by MATLAB Compiler SDK is intended to be used by other applications rather than using it back in MATLAB.
If you would like to share your program with other users who may or may not have MATLAB, you can create an executable using MATLAB Compiler. And, this can be executed in MATLAB using bang operator (!) or System command or from Windows command prompt.
0 Comments
See Also
Categories
Find more on MATLAB Compiler 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!