DLL creation to use in LabVIEW
Mostrar comentarios más antiguos
Hello,
I found one thread you've answered related with DLL creation from Matlab code and its usage in LabVIEW.
I'm trying to do it but until the moment I've not been successful, so, could you please help me with this?
I'm using "deploytool" in Matlab to generate the DLL but afterwards I do not know how to use it in LabVIEW. Could you please help me with this?
Thank you very much in advance.
Best regards, Filipe
Respuestas (3)
Kaustubha Govind
el 20 de Jun. de 2011
1 voto
You might have better luck getting specific help on NI forums.
However, for general guidance using MATLAB Compiler generated DLLs in an application, please see C Shared Library Target. I also found help on the NI website on How Do I Call a Dynamic Link Library (DLL) from LabVIEW?
Hopefully you should be able to deduce the required information from these two resources.
Ashish Uthama
el 20 de Jun. de 2011
1 voto
I believe LabVIEW can be viewed as the 'applications which loads a dll as a plugin' in this solution.
The trick is to wrap the MATLAB DLL in another layer to perform the MCR initialization part. The above solution has some example code you could look at.
3 comentarios
Kaustubha Govind
el 20 de Jun. de 2011
Ashish: According to this page, LabVIEW can dynamically load and unload a DLL: http://digital.ni.com/public.nsf/allkb/77594203D78D12278625729100758BE5
Since LabVIEW could be running the DLL multiple times per simulation (depending on the length of the simulation), loading and unloading the MCR and the compiled DLL each time will add considerable overhead. I think I've heard it mentioned before from other users that LAbVIEW VIs have an initialization and termination phase - it might be most efficient to initialize and terminate the MCR and compiled DLL in those phases.
Ashish Uthama
el 20 de Jun. de 2011
The wrapper code has logic to initialize once and reuse. The link appears to hint that the DLL is not unloaded by default unless one does additional steps.
It would be best to hook into these phases if possible, the wrapper code is not the easiest to follow/adapt.
Seng Vongsachang
el 5 de Nov. de 2015
Can someone please package a simple m function, create dll, write wrapper, and integrate into LV in a zip file if this has been successfully demonstrated.
David Roohy
el 16 de En. de 2019
1 voto
I've put together an example on how to do this from start to finish:
4 comentarios
ABHi
el 20 de Feb. de 2020
I've followed through your procedure and i am getting the following error
i am using labview 2016(64-bit), can you please help me with this error
David Roohy
el 20 de Feb. de 2020
The error indicates that you're missing a MATLAB Compiler Runtime component, so it's asking you to (re)install it.
Mohammad Reza Ramezani
el 6 de Sept. de 2020
Hi.
I've downloaded your work and followed it step by step but I've failed to compile the example Warpper.c that I wrote using your exact command (I'm using matlab2020) it says something about the "WinMain" function and I cant go furthermore.
anyway, I've skipped 3 and 4 sections and by using your actual .dll files I've created a .lvlib file but there is a broken arrow that says "The library specified for this node cannot be found or cannot be loaded". I've added exampleScript.dll to my directory and double-checked everything that you mentioned in your procedure but I still receiving that message. (I'm using the 2020 version of LabVIEW)
David Roohy
el 8 de Sept. de 2020
Hi Mohammad,
I don't have access to MATLAB 2020 or LabVIEW 2020 currently to try to reproduce. We eventually found the interoperability between MATLAB and LabVIEW such a complex interrelationship to maintain that we abandoned trying to call MATLAB in-process from LabVIEW. We now implement much of the math in LabVIEW and simply produce some plots in MATLAB afterwards through a call to a web service.
If LabVIEW says that it cannot load the DLL, then the DLL or one of its dependencies must be missing. The issue may even be related to the "WinMain" function error that your compliler complained about initially. I'm really not an expert here, but WinMain is the main entry point to all Windows applications programmed in C. If there's a problem with loading that function, then I can't expect you'd get very far. I would google the specific compilation error you received in MATLAB and then escalate to MATLAB support from there if your search doesn't give you any conclusive answers. Unless you get a functioning DLL that you can successfully build and call in MATLAB, I wouldn't expect you to be able to do the same in any other programming environment.
David
Categorías
Más información sobre LabVIEW 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!