Azzera filtri
Azzera filtri

DLL creation to use in LabVIEW

11 visualizzazioni (ultimi 30 giorni)
Filipe
Filipe il 20 Giu 2011
Commentato: David Roohy il 8 Set 2020
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

Risposte (3)

Kaustubha Govind
Kaustubha Govind il 20 Giu 2011
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
Ashish Uthama il 20 Giu 2011
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 Commenti
Ashish Uthama
Ashish Uthama il 20 Giu 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
Seng Vongsachang il 5 Nov 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.

Accedi per commentare.


David Roohy
David Roohy il 16 Gen 2019
  4 Commenti
Mohammad Reza Ramezani
Mohammad Reza Ramezani il 6 Set 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
David Roohy il 8 Set 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

Accedi per commentare.

Categorie

Scopri di più su Programming in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by