Dieser Inhalt liegt nicht in Ihrer bevorzugten Sprache vor.

Der Inhalt wird Ihnen in einer anderen verfügbaren Sprache angezeigt. Ihr Browser bietet ggf. Funktionen, die Sie bei der Übersetzung des Textes unterstützen.

What is a Wrapper DLL and When Do I Need One?

Updated Apr 12, 2024

Reported In

Software

  • LabVIEW Base
  • LabVIEW Full

Issue Details

What is a wrapper DLL, and when do I need one?

I need to call an external DLL in LabVIEW, but the parameters of the function do not easily map to LabVIEW data types.

Solution

A wrapper is a piece of software that provides a compatibility layer to another piece of software. One is often necessary when developing LabVIEW applications because third-party DLLs are typically designed to be accessed from C (or similar low-level languages) and not LabVIEW. Such a DLL may, for example, return pointers or complex data structures which LabVIEW cannot easily handle. 

Writing a wrapper DLL can be compared to writing a completely separate program in C that accesses the original DLL in the way the original author intended. In turn, this wrapper program has been specifically designed to be accessed from LabVIEW. In this sense, the new C program wraps around the original C program (DLL) and provides a layer of compatibility. The benefit of a wrapper is that the source code for the original DLL is not necessary, as it does not need to be modified in any way.

Additional Information

A common situation where a wrapper is needed is if a function in C or C++ has a union type as an input parameter or return value. This is because LabVIEW is incompatible with unions, due to strict typing rules that unions violate.
In this case a wrapper DLL would need to take a single value from LabVIEW and assign it to a union before passing it to the main DLL.