Call MATLAB-created DLL

8 次查看(过去 30 天)
Felix
Felix 2017-3-3
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)

回答(1 个)

Nagarjuna Manchineni
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.

类别

Help CenterFile Exchange 中查找有关 C Shared Library Integration 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by