DLL creation to use in LabVIEW
13 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(3 个)
Kaustubha Govind
2011-6-20
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.
0 个评论
Ashish Uthama
2011-6-20
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 个评论
Ashish Uthama
2011-6-20
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
2015-11-5
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
2019-1-16
I've put together an example on how to do this from start to finish:
4 个评论
Mohammad Reza Ramezani
2020-9-6
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
2020-9-8
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
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!