Additional Information

When using the C calling convention, the caller is responsible for cleaning up the stack. When using the standard calling convention, the called function is responsible for cleaning up the stack. If the caller (LabVIEW) and the called DLL function do not use the same calling convention, then they will either both take things off the stack or neither of them will. Either situation can cause LabVIEW to crash when the called function returns. If you do not wire the inputs, the DLL function will overwrite unallocated memory. If you do not wire the outputs, LabVIEW assumes the DLL function does not need the allocated memory passed on the input side and will use it for something else. Many DLL functions take allocated memory, passed by pointer or value, write to this memory, and return it. If the memory is not allocated properly, it may cause a crash. For example, consider the following function:



double *Waveform (double *waveform, uInt32 size);



The proper way to allocate the memory in this case is to initialize the array with the number of elements specified by the size parameter, not by passing in an empty array. The image below demonstrates the proper method.

The Call Library Function Node must be set so that the DLL call is allowed to run in any thread. This is set by changing the thread radio button from Run in UI thread to Run in any thread.

Note: All calls to LabVIEW-built shared libraries should specify Run in any thread. If you configure the Call Library Function Node using LabVIEW-built shared libraries and specify Run in UI thread, LabVIEW might hang and require you to restart. For more information, reference All calls to LabVIEW-built shared libraries should specify. If you configure theusing LabVIEW-built shared libraries and specify, LabVIEW might hang and require you to restart. For more information, reference Call Library Function Dialog Box

The calling VI must not be running in the User Interface thread. This can be checked by selecting File»VI Properties from the pulldown menu, selecting Execution from the Category list and making sure that the Preferred Execution System is standard, instrument I/O, data acquisition, other 1, or other 2. The same as caller option should not be chosen because the parent VI could be running in the user interface thread.

Call Library Function Node

Error Checking Level -Contains the following options: Maximum -Enables the maximum level of error checking for the Call Library Function Node. If you enable the maximum level of error checking, the Call Library Function Node returns an error if the Calling convention you select on the Function tab does not match the calling convention of the function you are calling in the shared library or DLL. The maximum level of error checking also returns a warning if the function being called in the shared library or DLL writes beyond the space allocated for the specified string or array parameter. The maximum level of error checking allows LabVIEW to recover from unhandled exceptions that occur during execution of the called shared library or DLL.

-Contains the following options:

Note: Selecting the Maximum control on the Error Checking tab reduces the execution speed and increases the memory usage of the Call Library Function Node. Therefore, you should select the Maximum control only when debugging your configuration of the Call Library Function Node .

Default -Enables the default level of error checking for the Call Library Function Node. The default level of error checking allows LabVIEW to recover from unhandled exceptions that occur during execution of the called shared library or DLL.

-Enables the default level of error checking for the Call Library Function Node. The default level of error checking allows LabVIEW to recover from unhandled exceptions that occur during execution of the called shared library or DLL. Disabled-Disables error checking for the Call Library Function Node. Disabling error checking for the Call Library Function Node improves the execution speed of the Call Library Function Node. However, certain errors can cause an irregular shutdown of LabVIEW. Before disabling error checking, be sure that the function the Call Library Function Node references does not raise any unhandled exceptions.

For complete documentation on how to use LabVIEW code with other programming languages in LabVIEW 7.1 or earlier, refer to the Using External Code in LabVIEW manual. In LabVIEW 8.0 or later, refer to thesection in the LabVIEW Help table of contents for more information.Your VI might still run in Development mode without following these steps. However, when making an application, be sure to set the the calling VI to Run in any thread as stated above.The most likely problem is that the DLL function being called has corrupted the memory. If you pass arrays or strings to the DLL, the DLL function cannot dynamically resize the array. Writing beyond the last element of the array or string could corrupt the memory and this may not be obvious until LabVIEW is closed.—Use the Error Checking tab to specify thefor theThis tab includes the following components: