LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling manager functions from a compiled program

Hello,

  I have an application that used Call Library Function nodes to do some of its dirty work.  The DLL file called uses a few manager functions for memory resizing and such, so it's linked against labview.lib as described in http://digital.ni.com/public.nsf/allkb/01BD203DE97AEBA986256800007546BB.

  The problem is that when I create a build specification to make an executable that we can distribute, the application stops working because it can't locate LabVIEW.exe to load the manager functions.  I tried rebuilding the labview.lib file so the DLL would look for the functions in the built application, but they none of the symbols were found and the application ended up with a broken run arrow.

  How can a DLL access functions like DSNewHandle and Occur?

Thanks,
Adam Brewster
0 Kudos
Message 1 of 4
(3,071 Views)


@adambrewster wrote:
Hello,

  I have an application that used Call Library Function nodes to do some of its dirty work.  The DLL file called uses a few manager functions for memory resizing and such, so it's linked against labview.lib as described in http://digital.ni.com/public.nsf/allkb/01BD203DE97AEBA986256800007546BB.

  The problem is that when I create a build specification to make an executable that we can distribute, the application stops working because it can't locate LabVIEW.exe to load the manager functions.  I tried rebuilding the labview.lib file so the DLL would look for the functions in the built application, but they none of the symbols were found and the application ended up with a broken run arrow.

  How can a DLL access functions like DSNewHandle and Occur?

Thanks,
Adam Brewster


You should definitely use "LabVIEW" as library name and not "Labview.exe". The DLL executes in the context of the runtime engine and the executable of that is called lvrt.exe and not labview.exe.  But LabVIEW has special treatment of the keyword LabVIEW in the library name of the Call Library Node.

Rolf Kalbermatter

Rolf Kalbermatter
Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 4
(3,056 Views)


@adambrewster wrote:
Hello,

  I have an application that used Call Library Function nodes to do some of its dirty work.  The DLL file called uses a few manager functions for memory resizing and such, so it's linked against labview.lib as described in http://digital.ni.com/public.nsf/allkb/01BD203DE97AEBA986256800007546BB.

  The problem is that when I create a build specification to make an executable that we can distribute, the application stops working because it can't locate LabVIEW.exe to load the manager functions.  I tried rebuilding the labview.lib file so the DLL would look for the functions in the built application, but they none of the symbols were found and the application ended up with a broken run arrow.

  How can a DLL access functions like DSNewHandle and Occur?

Thanks,
Adam Brewster


On second thought reading your question again, it may also be that you rather write your own DLL in something like Visual C and are using LabVIEW manager calls. In that case you should simply link your project with labview.lib from the cintools directory. The import loader in that library does account already for the possibility of the dll running in the runtime system and first tries to link to labview.exe and if that fails to lvrt.dll automatically. I know for sure that this works since at least LabVIEW 5.1 or so, so if you see something else then you do something wrong.
Definitely don't try to import the functions yourself with LoadLibrary() and GetProcAddress() as this will not easily work in the runtime system due to your application process not being called "labview.exe" but "yourapp.exe" and the LabVIEW manager functions being provided by "lvrt.dll" instead. Unfortunatly to be robust it is not enough to just try to load "labview.exe" first and if that fails for whatever reasons trying to do LoadLibrary("lvrt.exe"). This may work sometimes but may give you problems under certain situations so linking with labview.lib instead is really the best and also most simply way.

Rolf Kalbermatter
Rolf Kalbermatter
My Blog
Message 3 of 4
(3,045 Views)
I guess I screwed up linking the DLL. I'll take another swing at it on Monday morning. Thanks for your help.
0 Kudos
Message 4 of 4
(3,043 Views)