Archived:Using External CIN and DLL Code in LabVIEW

Updated Dec 5, 2018

National Instruments does not actively maintain this document.

This content provides support for older products and technology, so you may notice outdated links or obsolete information about operating systems or other relevant products.

Reported In


  • LabVIEW Full
  • LabWindows/CVI Full

Issue Details

I want to call external code from LabVIEW, but I am not sure where to start. How can I do this?

Additional Information

Below is a list of topics that you should become familiar with.
  1. CIN & DLL Starting Point
  2. Using CINs in LabVIEW Base Package
  3. Optimization and Performance Issues for External Code in LabVIEW 7.x
  4. How To Compile CINs and Shared Libraries with GCC on Solaris
  5. Compilers that support CINs in LabVIEW
  6. Create a CIN with LabWindows/CVI 4.x and Above

1. CIN & DLL Starting Point
If you are using Microsoft Visual Studio .NET 2003, a great reference would be the tutorial Creating a CIN Project in Visual Studio .NET 2003. It describes how to configure Microsoft Visual Studio .NET 2003 to create a Code Interface Node (CIN) project to write CIN code for use in LabVIEW 7.1.

2. Using CINs in LabVIEW Base Package
Although CINs are used in the LabVIEW Base Package and show up in the functions palette, they are not supported for application development. The necessary files for creating CIN object files (.lsb) do not come with the base package.

The Base Package does indeed allow you to use CINs, but it does not include the tools to build the code that is used by the CIN. You will need to purchased the Full Development System or higher if you want to do this. This is why the CIN is present in the palette but the Cintools directory under LabVIEW is absent. There are several steps involved in creating a CIN:
  1. Put the node on the diagram and wire up the inputs and outputs.
  2. Create the .c file from the CIN's pop-up menu
  3. Edit the .c file and insert your code.
  4. Create a code resource file (.lsb) from your .c file. To do this, you need the "CIN Tools"
  5. Load the code resource file (.lsb) from the CIN's pop-up menu.
Note: The base package does not provide the tools to do step 4. However, if you have pre-existing code resource files (.lsb), you may still use them in the base package.

3. Optimization and Performance Issues for External Code in LabVIEW 7.x
You should strongly consider using thread-safe CINs and DLLs. A CIN or DLL is thread-safe if it can reliably be called from two or more separate threads. Since CINs and DLLs that are thread-unsafe must be run in the user interface thread, any call to such a CIN or DLL causes LabVIEW to switch execution from the block diagram's thread to the user interface thread.

There is overhead associated with this switch. The CIN or DLL will run to completion in the user interface thread before relinquishing control to the thread, so the user interface will appear unresponsive during this time. By default, LabVIEW considers all CINs and DLLs to be thread-unsafe. The reason for this is that the computer may crash or hang if LabVIEW assumes a CIN or DLL to be thread-safe when it is actually thread-unsafe.  

To identify a CIN to LabVIEW as being thread-safe, you must include certain function calls in the CIN. For more information reference the Calling a 32-bit DLL from a Code Interface Node (CIN) in LabVIEW. You can also see Chapter 3 of the LabVIEW Code Interface Reference Manual»CIN Advanced Topics, for more information.

4. How To Compile CINs and Shared Libraries with GCC on Solaris
Please reference How Do I Compile CINs on Unix / Linux? which will covers the steps on how to compile.

5. Compilers that support CINs in LabVIEW
For a list of compilers that support CINs for LabVIEW 5.x see the Code Interface Reference Manual.

Here is a list of compilers for LabVIEW 4.x:
  • Macintosh: Symantec’s THINK environment, Metrowerks’CodeWarrior environment, GCC, and Apple’s Macintosh Programmer’s Workshop (MPW) environment
  • Microsoft Windows 3.x: Watcom C 
Note: Compiler must be able to create 32-bit relocatable object code
  • Windows 95/NT: Microsoft Visual C++ compiler and Symantec C compiler​
Note: With some restrictions, you can also use some CINs created using Watcom C for Windows 3.1
  • Solaris 1.x and 2.x: unbundled Sun C compiler​
Note: LabVIEW for Sun can use external code compiled in a.out format and prepared for LabVIEW using a LabVIEW utility
  • HP-UX and Concurrent PowerMAX: HP-UX C/ANSI C compiler and Concurrent C Compiler
  • PowerMac: Metrowerks CodeWarrior C/C++ and Symantec C++ Version 8
  • Linux: GCC
6. Create a CIN with LabWindows/CVI 4.x and Above
The detailed instructions on how to create a Code Interface Node from LabWindows/CVI is given in the cvilvsb.h file which can be found in LabVIEW/cintools folder.

Please reference How to Create a LabVIEW Code Interface Node (CIN .lsb File) with LabWindows/CVI 4.x and Above for more information.