Calling Shared Libraries

LabVIEW 2018 Help

Edition Date: March 2018
Part Number: 371361R-01
View Product Info

DOWNLOAD (Windows Only)

LabVIEW 2016 Help
LabVIEW 2017 Help
LabVIEW 2018 Help
LabVIEW 2019 Help
LabVIEW 2020 Help

A shared library is a file containing executable program modules that any number of different programs can use to perform some function. You can call these program modules, or shared library functions, from LabVIEW by using the Call Library Function Node. Call a shared library function when you want to accomplish any of the following tasks:

  • Using functions written in another programming language within LabVIEW
  • Performing tasks that LabVIEW cannot perform with its own functions and VIs, such as calling system routines
  • Completing tasks that are better suited for text-based languages

Shared Libraries on Different Platforms

(Windows) A shared library is called a DLL.

(OS X) A shared library is called a Framework.

(Linux) A shared library is called a Shared Library function.

General Approach to Calling Shared Libraries

Calling a shared library function in LabVIEW includes the following actions:

  1. You obtain or create a shared library.
  2. You configure a Call Library Function Node to call a function within the shared library.
  3. LabVIEW calls the function when the Call Library Function Node executes.
  4. LabVIEW passes input data from the block diagram to the executable code.
  5. LabVIEW returns data from the executable code to the block diagram.

After you configure a Call Library Function Node to call a shared library function, you can change the shared library without changing the calling VI or the Call Library Function Node, provided you do not modify the function prototypes.

LabVIEW loads shared libraries in a unique application instance. Opening a shared library in a unique application instance prevents naming conflicts with VIs in the shared library, and VIs outside of the shared library.

Limitations on Calling Shared Libraries in LabVIEW

  • Shared libraries must use either the stdcall or C calling convention. You can use any language to write shared libraries as long as the shared libraries can be called using one of these two calling conventions.
  • Shared libraries execute synchronously. You cannot reset a VI that is running a shared library until execution completes. If you want to write a shared library that performs a long task, be aware that LabVIEW cannot perform other tasks in the same thread while the shared library executes.
  • VIs that call shared libraries are platform specific. VIs that call functions within shared libraries execute on different platforms only if you have a corresponding library for each platform. If you move a VI that call a shared library with a Call Library Function Node to another platform, you must update the node to specify the version of the shared library that is compiled for the new platform.

Examples and troubleshooting information help you build and use shared libraries and successfully configure the Call Library Function Node in LabVIEW. The general methods described here for DLLs also apply to other types of shared libraries. Refer to the labview\examples\dll directory for examples of using shared libraries.

Note   (MathScript RT Module) You also can use functions that belong to the MathScript RT Module libraries class to call shared libraries from the LabVIEW MathScript Window or the MathScript Node. Refer to the MathScript Shared Libraries.lvproj in the labview\examples\MathScript\MathScript Shared Libraries directory for examples of calling shared libraries from the MathScript RT Module.


Not Helpful