LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I create a DLL using MATLAB that LabVIEW can understand?

Hello,

I've written a MATLAB program that I can use with LabVIEW.  I would like to deploy my application so that other people who do not own MATLAB and LabVIEW can use my application.

I have the MATLAB compiler, and I am able to compile the code and generate a DLL.  Unfortunately, I am unable to get LabVIEW to use this DLL.

I understand that in order to do this I must write a wrapper DLL.  How can I go about this?  I've found the online documentation to be very confusion.

Thanks,

Mark

0 Kudos
Message 1 of 5
(4,768 Views)

Hi Mark,

 


It looks like you need the wrapper DLL because there are differences in the way that MATLAB and LabVIEW store data.  It has also been noted that there is some sort of MATLAB Run-time engine.  I would take a look at these forum topics, and if you are still unable to create a wrapper in C/C++, let me know.  There may also be some resources from Mathworks.

http://forums.ni.com/ni/board/message?board.id=170&message.id=29793&requireLogin=False
http://forums.ni.com/ni/board/message?board.id=170&message.id=91847&requireLogin=False
http://forums.ni.com/ni/board/message?board.id=170&message.id=147690&requireLogin=False
http://forums.ni.com/ni/board/message?board.id=170&message.id=203572&requireLogin=False



Trey B
Applications Engineering
National Instruments

0 Kudos
Message 2 of 5
(4,743 Views)

I've been trying to do the same thing, and have just about tried every example listed on NI and Mathwork's websites.

The last attempt I made was to follow the procedure in http://www.mathworks.com/support/solutions/data/1-2Q3TJ5.html?product=CO&solution=1-2Q3TJ5.

Here it talks about compiling a simple code for use with a win32 console application.  I started with a trial version of the Matlab compiler (ver. 2007a), and followed the build instructions for Matlab.  Then I opened up MSVS 2005 and created a new project.  Here I selected a win32 application instead of a console application (so I could choose a DLL).  After following all the steps, I built the solution and ended up with a test.dll shared library.  Next, I made a vi and inserted a code interface node, and tried to configure the DLL.  My impression was all I needed to do was select the test.dll and add the arguments.  But that doesn't seem to be the case.  I even tried putting the matlab dll and lib in the same directory as the test.dll.  That didn't work either.  I switched back to the matlab dll, and it still fails.  I can't seem to figure it out.  Since I've got Matlab and Labview on the same machine, I'm assuming I don't need to install the mcr on my computer.  I understand that if I move to another machine, I'd have to do that somehow.  Also note that I'm using LV 7.1.

Any help would be greatly appreciated.   As I said, I followed all the instructions in the Matlab example (save making it a dll instead of a console app).  I seem to be missing something.

0 Kudos
Message 3 of 5
(4,665 Views)
G.M.,

Have you looked at the forum topics about wrapper DLLs?

Trey B
Applications Engineering
National Instruments
0 Kudos
Message 4 of 5
(4,650 Views)

Trey,

I have looked at the forums discussing wrapper DLLs.  I specifically tried the one specified in the Matlab example (foowrap.c).  My impression was you add this code to your original library and build them together.  That way, all the code gets built into a single DLL, with the wrapper talking to the library I built with the Matlab compiler.

The process as I understand it is:

1) Write Matlab m-file.

2) Build dll with Matlab compiler.

3) Create new dll with MSVS 2005.

4) Include library files and write wrapper code for the function.

5) Build the solution to a new dll.

6) Use a code interface node in Labview to talk to the MSVS 2005 dll.

Is this not the correct approach to getting it to work?  Thanks for responding by the way!

0 Kudos
Message 5 of 5
(4,642 Views)