필터 지우기
필터 지우기

How to create a dll from a Matlab code

조회 수: 173 (최근 30일)
isazetl
isazetl 2014년 11월 27일
답변: Crystal Li 2019년 2월 19일
Hello everyone,
I'm new on this forum, and I need your help on a problem.
I do not know if the title of the topic is very clear, so I will explain a little more my problem.
I made one or more functions on MATLAB in .m .
My goal is to use these function(s) via an editing HMI software. This software has a "function" that allows to import a dll library, then use one or more C functions by specifying different parameters.
So for that, I must first convert my .m in .c then create a dll all from Matlab ( because I have to add to MCR install the redistributable etc ...) tell me if I'm wrong, I'm discovering the dll ...
What I 've done for now :
I tried to use Matlab Coder to create a dll, stating clearly in the Build tab in settings , "C / C ++ Dynamic Library" for output type . Only I do not get a dll, but "only" the .h and .c files , here is an example of what I get:
With Matlab Compiler, I managed to create a dll from a .m code which gives me this:
I can import the dll library in the HMI software but I can not use functions included in the DLL , the software "does not find the function".
I am using Matlab R2012b .
If anyone sees what am I doing wrong ...
Thank you for helping me !
  댓글 수: 2
Ryan Livingston
Ryan Livingston 2014년 12월 2일
편집: Ryan Livingston 2014년 12월 2일
Is the "Generate code only" check box checked on the "Build" tab? If you uncheck that, the generated code should be compiled into a DLL.
Farhad VISHKAEE
Farhad VISHKAEE 2016년 6월 22일
편집: Farhad VISHKAEE 2016년 6월 22일
Hello,
Using this technique, you will then need a wrapper to generate your DLL.
Please follow the instruction in this PDF which directly goes to a stand alone DLL:
https://www.mathworks.com/matlabcentral/answers/uploaded_files/31889/MATLAB%20-%20C.pdf
Good luck ;)

댓글을 달려면 로그인하십시오.

답변 (2개)

Jorik
Jorik 2014년 12월 4일
MATLAB Coder and MATLAB Compiler are very different products, but both can indeed generate a DLL for interfacing with other applications. The product pages explain the use cases for these products quite well:
For MATLAB Coder the target must indeed be set to "C / C ++ Dynamic Library" in the project and the generated code must also be built (uncheck "Generate code only". The DLL is then generated in the codegen/dll/[project] directory, the following code generates a DLL for a shipping demo file hello_world.m
>> coderdemo_setup('coderdemo_hello_world');
>> codegen -config:dll hello_world
And then you should have a codegen/dll/hello_world/hello_world.dll.
  댓글 수: 1
Alden fuchs
Alden fuchs 2015년 3월 13일
ok got dll but there are no callable functions in it

댓글을 달려면 로그인하십시오.


Crystal Li
Crystal Li 2019년 2월 19일
I have the similar questions. May I ask how to do it? Thanks in advance!
https://ww2.mathworks.cn/matlabcentral/answers/445511-how-to-hybrid-programming-to-dll-file

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by