LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Could Use some Advice on Matlab function to .dll to labview .vi

Hi Folks,

 

I'm trying to build a .dll shaired library from a function I wrote in matlab and call it from a labview vi, preferably building such a vi using the "Import Shaired Library" wizard in labview. I could use some advice as I've been working on this for a while without much luck. See below for the type of errors I've been getting.

 

FYI I'm working with the latest version of Matlab R2012a (17.14.0.739) and the Matlab Compiler, and Labview 2011 sp1. The compiler has been set up to use my installed full version (not a trial) of MS Visual Studio Professional 2010.  I'm still at the point where I use a silly Matlab test function "timestwo.m" that outputs 2 times the input, so nothing unusual about the function, i.e. no complex data types, etc. Also FYI I'm a Physicist, and while I'm pretty proficient with Labview and Matlab, and can program basic c++, I have no prior experience builiding and using .dlls, so this is currentl a dark forest for me.

 

I'm attempting to compile the .dll with the Matlab comand -

 

mcc -t -L C -Wlib:C:mylib123 -Tlink:lib -h timestwo.m libmmfile.mlib

 

And this generates the mylib123.dll and a header file mylib123.h.  When I naively then go to the "Import Shaired Library" wizard to attempt to build a vi from the .dll and .h files I get an several errors most of all having to do with "The following symbols are not defined: MW_CALL_CONV;". Seem like I need a wrapper but that includes something else, but I have been unable to figure this out on my own. I've also tried out the wrapper method and example here:

 

http://www.mathworks.com/help/toolbox/compiler/f2-972343.html

 

that was reffered to here by an NI software person:

 

http://www.mathworks.com/matlabcentral/answers/9865-dll-creation-to-use-in-labview

 

But the example did not work for me in the wizard after loading the .dll and .h files. However I did get fewer errors, and of a different type.

 

Can anyone point me to some information on how to proceed here? I'm still looking for information but have begun to feel like I've reached a dead end.

 PS. Already know about and use mathscript, etc. I'm afraid I really do need to build an executable for a target that does not have matlab.

0 Kudos
Message 1 of 6
(3,373 Views)

I did find this:

 

http://forums.ni.com/ni/attachments/ni/170/29800/1/dllmatlablabview.pdf

 

which is in just the right style - specific enough for even me to follow. But it seems old. I'm working through this now. Does anyone have an opinion if this is up to date enough?

 

0 Kudos
Message 2 of 6
(3,366 Views)

Hello,

 

The document you linked looks like proper directions. It is very old, but is probably a good start.  If you have further questions about compiling a DLL in MATLAB ® I recommend you contact Mathworks Support.

 

Regards,

Matt M.

 

 

Matlab is a registered trademark of the Mathworks Corporation.  All copyrights and trademarks are property of The MathWorks, Inc.

 


Applications Engineer
National Instruments
0 Kudos
Message 3 of 6
(3,343 Views)

I think his issue is that the Import Shared Library wizard cannot find the definition of certain types, like MW_CALL_CONV. These are Matlab types, and would be defined within the Matlab compiler header files. Thus, you need to inform the wizard to include these header files when trying to import the library. These header files should be installed somewhere within the folder structure of Matlab. As to where, I haven't a clue, but it should be specified somewhere in the Matlab documentation.

0 Kudos
Message 4 of 6
(3,339 Views)

Hi Millonas,

 

Did you get any luck with this, I will like to know how you resolved the issue. I am currently in the same situation.

 

Many thanks

Gerald

0 Kudos
Message 5 of 6
(2,582 Views)

I've put together an example on how to do this from start to finish:

 

https://forums.ni.com/t5/Example-Program-Drafts/Walkthrough-for-Creating-a-MATLAB-DLL-That-Can-Be-Ca...

0 Kudos
Message 6 of 6
(2,439 Views)