LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Failure: "gnrclist.cpp" after a DLL call

Forum:
 
Since adding dll calls in a VI, LabVIEW is frequently crashing, both during VI execution and after exiting the application.
 
Generally, what issues need to be considered when making successful dll calls (using the "call library function").
 
Jordan
0 Kudos
Message 1 of 4
(2,646 Views)
The fundamental problem that comes up when dealing with Call Library nodes is correctly (a) declaring the parameters to the method and (b) mapping them to LV data types. Often when dealing with parameters that are pointers, array and especially structures, a small error in declaration can result in memory corruption. Also, DLL's support different calling styles (cdecl, stdcall, etc) and declaring the wrong one can result in the stack becoming corrupt.
 
If you can instead use COM/ActiveX or .NET instead (not sure what you are calling out to), then LV can do all the heavy lifting for you. Unfortunately normal DLL's just don't provide the information necessary for LV to automatically handle the issues.
0 Kudos
Message 2 of 4
(2,637 Views)

Hi Jordan,

It sounds like this issue is due to the fact that you are not allocating memory for the dll in advance. This is the most common mistake when implementing a dll in LabVIEW.

For instance, if your dll is going to output an array of 100 double-precision numbers, then you need to allocate this place in memory by passing the dll a dummy array of 100 double-precision numbers that it can operate on. Also be careful not to expand the size of the array. LabVIEW doesn't support dynamic memory allocation within a dll in most circumstances. If you don't allocate a place in memory in advance, LabVIEW may crash when you exit the program and LabVIEW tries to deallocate memory.

A really good example of allocating various types of data for use in a dll is available from the Example Finder (Help >> Find Examples from LabVIEW).  Click the Search tab and search for the term DLL. The Example is called Call DLLs. It contains c code that corresponds to various dll functions that operate on various data types, and it shows you how to call these dll functions properly from LabVIEW. For a more comprehensize overview of the process, refer to the document Using External Code in LabVIEW, available here, or browse through these Developer Zone examples and applications notes.

Jarrod S.
National Instruments
Message 3 of 4
(2,632 Views)

Lycangeek and Jarrod:

Thank you for your useful responses to my labview-dll trouble.  Yes, it turns out that a dummy string variable/pointer I was passing to a given function of the dll was not correct.  Since correcting this, the dll-call works without returning an error-value and labview is not crashing!

Much Appreciated,

Jordan

0 Kudos
Message 4 of 4
(2,626 Views)