LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a LabVIEW-built DLL in LabVIEW - is this the correct set of instructions?

I created/built a DLL in LabVIEW 8.2.  I now want to try to call that DLL from LabVIEW for test purposes.  I am not clear on the procedure to do this but found the link:

http://zone.ni.com/reference/en-XX/help/371361B-01/lvhowto/building_a_shared_library_dll_/

Is this the procedure I should be following, or a better example procedure?

Sincerely,

Don
0 Kudos
Message 1 of 19
(4,413 Views)

Don,

The documentation you link to is primarily geared at building a dll to call from LabVIEW in an external IDE (such as Visual Studio). 

You may want to look at this example to see how to call the dll you created in LabVIEW:
https://www.ni.com/docs/en-US/bundle/labview/page/example-1-call-a-shared-library-that-you-built.htm...

In short, all you need to do is place a "Call Library Function Node" on your block diagram and then double click on it to bring up it's configuration dialog.  Within the configuration dialog you can point it to your dll and select the function you want (typically it will be the name of your dll) at which point LabVIEW should automatically populate the parameters tab.

Give it a try and if you run into any trouble let us know and we'll be happy to help.

Regards,

Simon H
Applications Engineer
National Instruments

 
0 Kudos
Message 2 of 19
(4,397 Views)
I tried this for my PCA.dll but it appears one may have to manually populate the parameters (no automatic population occurred).  Am I correct about this?
 
Sincerely,
 
Don
0 Kudos
Message 3 of 19
(4,372 Views)
Yes you are correct.

I wrote the previous response from memory and got the autopopulation of the parameters mixed up with the functions.

Sorry for the confusion.

~Simon
0 Kudos
Message 4 of 19
(4,355 Views)
.....Wouldn't it be nice for automatic population to occur (oh well...)....Don
0 Kudos
Message 5 of 19
(4,347 Views)
Hi Simon:

I manually populated the parameters but there must still be something that I am doing that is not right as I get the error "One or more required inputs to this function are not wired or are wired incorrectly."  I have a test program (test_labview_created_dll.vi) I created and have also included the dll in the zip file.  I have looked at some of the help files but I expect there are some intricacies regarding specifying inputs and outputs that I am missing.  I wondered if you could please take a look and advise or get one of your experts at external code interfacing to take a look.

The reason that I want to validate the operation of a LabVIEW-created DLL in LabVIEW is because then I can hand it off to someone who will interface it in visual c++ and tell them I at least had it tested, interfaced and working properly in LabVIEW.

Sincerely,

Don
0 Kudos
Message 6 of 19
(4,329 Views)
Don,

I took a look at your test program and that error can be explained by the fact that you didn't wire anything to the #PCA Images input on the call library node.

If you wire a control to this input your dll should run.



I hope this helps,

~Simon

Message Edited by Simon H on 11-13-2006 01:22 PM

0 Kudos
Message 7 of 19
(4,300 Views)

I stared and stared without seeing that.  Sometimes you just need a second set of eyes which is why I post here when I have problems.  Will let you know when I get it running.  Thanks again.

Sincerely,

Don

0 Kudos
Message 8 of 19
(4,286 Views)
 

Well I guess we are not going to get off that easy.

To test the code, I went back to the beginning and first made sure the LabVIEW source (prior to building DLL) was running correctly which it was (PCA_test.vi). I then built the DLL from the PCA.vi (same as PCA_test.vi but with necessary controls to successfully build the DLL), and took the values that validated the source code and made them into constants for the input parameters to be fed into the built DLL to perform the analagous fx in the test VI (test_labview_created_dll.vi). The latter VI containing the DLL runs without error, but hangs forever.  It should run rather quickly as the LabVIEW source runs in a few seconds or less.  I checked to make sure that the constants are of the correct type (I actually just popped up on DLL terminals to form constants).

I then deleted what I thought was any suspect code such deallocation of memory, references, local variables, etc. and repeated with the same result (hanging).

Since I have included a sample set of images as constants in the code, it is somewhat large and not really attachable, so I have put it on your ftp site.  The name of it is test_labview_created_dll.zip. Any insight you can provide would be greatly appreciated as this is critical to validate this code library.

Sincerely,

 

Don

0 Kudos
Message 9 of 19
(4,275 Views)

Don,

I think the reason your DLL is hanging is that it is attempting to run in the UI thread along with the calling VI and this is causing a deadlock (see the last bullet on the first linked page).

Here are some other links that I think you might find useful for debugging purposes if you haven't already found them.
Why Does LabVIEW Crash When I Call My DLL?

 

Debugging DLLs and Calls to DLLs

Integrating LabVIEW Code into Other Programming Languages

I also found this old post regarding a similar situation.

Another tip that may help you is that PCA.h in your PCA folder contains the type definitions and function prototype required to call the DLL from C.  This makes interfacing with text based code a little easier. 

I hope this helps.

~Simon

 
0 Kudos
Message 10 of 19
(4,253 Views)