LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling External Libraries Dynamically

I have an application build in Labview and a lot of libraries that work as my data source.
 
What I need to do is an application that links the external library dinamically. The user will choose the data source that he wants to monitor and the software will create the link in this time.
 
All external libraries have the same patterns of parameters and the returned values are in the same type.
 
Somebody could give me a suggestion? I read something related in VI Server Tutorial, but that tutorial only explains how to do it with VIs not with external libraries.
 
Thank you in advance.
0 Kudos
Message 1 of 5
(2,970 Views)


@Oliveira wrote:
 
What I need to do is an application that links the external library dinamically. The user will choose the data source that he wants to monitor and the software will create the link in this time.
 
All external libraries have the same patterns of parameters and the returned values are in the same type.
 

When the user chooses the data source that he wants to monitor, U pass a Str constant, specifying the Dll function for that particular thing to chosen to be monitored by the user, as the first input to the Dll. The only change to be made will be to include an input in the Dll that can accept this Str constant ( respective function name ) as one input ( probably the first one ).

Hope this helps Ur work to get proceeded...

- Partha ( CLD until Oct 2027 🙂 )
Message 2 of 5
(2,964 Views)
Following the way that you explain, I will have to develop a interface, maybe using C. Do you have any idea in how to solve this problem using only the Labview features?

Thank you in advance.

Message Edited by Oliveira on 03-26-2007 01:34 PM

0 Kudos
Message 3 of 5
(2,959 Views)
There are two LabVIEW-centric solutions to this that I can think of. You can evaluate if these fit your needs.

  • In LabVIEW 8.2, you can specify a path on the block diagram for the library to load. LabVIEW won't statically link to this library, but rather dynamically at run-time. The name of the function and the parameters have to be the same, regardless of which library gets loaded. You can't do this with LabVIEW 8.0 or previous. This link should help you out with more details.
  • You could have a number of different VIs that statically link to a different external libraries. You could then use VI Server to dynamically choose which of these VIs to load and execute. Set all the VIs to have the exact same connector pane, then you can use a Call by Reference Node to execute them almost like you would a subVI, except that you control which VI to load and when to unload it. Here's a tutorial that should help.
Jarrod S.
National Instruments
0 Kudos
Message 4 of 5
(2,943 Views)


@Oliveira wrote:
Following the way that you explain, I will have to develop a interface, maybe using C. Do you have any idea in how to solve this problem using only the Labview features?

Thank you in advance.

Message Edited by Oliveira on 03-26-2007 01:34 PM



What I had told U was itself LabVIEW feature. What U ve to do is make one more inout in the Dll for the Function name as a Str or a Path to get it loaded into memory dynamically during run-time only. This will naturally happen in Ur code because U ve told us that the user himself is going to choose the corresponding functionality.

So, if the choice is thro' a menu ring, for example, all U ve to do is for each item of the ring wired inside a case structure will be sitting these corresponding Str constant or Path constant, which in turn will be wired to the first input of the Dll (NOT necessarily first). This ll invoke the corresp[onding function of the Dll or the corresponding Dll itself, whichever suits best Ur application.

Why I'm telling U this is, in my project, I'm following this methodology only to invoke differerent functions for various H/W modules, but that re present only in the same Dll itself. The parameter numbers & their order are the same for the diff cards. So,we vr got the Dll function name as the first input of the Dll. We use Path instead of Str because when LV builds the EXE, it puts all the necessary Dlls in the code into a folder called "data" that is created in the directory where U build the EXE (for eg, Desktop).

Then U can copy Ur application to wherever U wish to...

On the other hand, U can tell LV where it needs to install Ur application if U create a installer for it.

If U re working in <=LV8.0, this is the only st fwd procedure to acheive things as U want now.

Only from LV8.2, U can import the Dlls by using the Export/Import Dll wizard directly into LV as sub-VIs & perform dynamically loading them alike VIs using the VI server method (using Call by Reference node).

Hope this explains thing in clear detail to U.

- Partha ( CLD until Oct 2027 🙂 )
Message 5 of 5
(2,933 Views)