LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Building a LabVIEW DLL with VIs that use CINs

I am trying to create a shared library (DLL) from Labview 8.2.1 to make some Labview code available to another application being created in Visual Studio.  Some of the Labview VIs include CINs created while using previous versions of Labview. I can use the DLL functions from a test labview application, but when the external application loads the DLL, a dialog box appears with the message Fatal Error: "LABVIEW.LIB was not called from a LabVIEW process."
 
The VIs containing the CINs are also used without error when building regular Labview applications (EXEs).
 
After commenting out all of the CINs and rebuilding the DLL, the error goes away.  Any suggestions?
0 Kudos
Message 1 of 5
(3,693 Views)

After some more analysis, I realized that one of the CINs is using a memory manager function:

   #ifdef DOUBLE_PRECISION
       if (err= NumericArrayResize(fD,1L,(UHandle*)&newData,*newNpts)) goto out;
   #else
       if (err= NumericArrayResize(fS,1L,(UHandle*)&newData,*newNpts)) goto out;
   #endif

I suspect that this may be related, but still am not sure of the solution.

0 Kudos
Message 2 of 5
(3,687 Views)


@TBonanno wrote:

After some more analysis, I realized that one of the CINs is using a memory manager function:

   #ifdef DOUBLE_PRECISION
       if (err= NumericArrayResize(fD,1L,(UHandle*)&newData,*newNpts)) goto out;
   #else
       if (err= NumericArrayResize(fS,1L,(UHandle*)&newData,*newNpts)) goto out;
   #endif

I suspect that this may be related, but still am not sure of the solution.



Well, all invocations of the exported external code functions among which the memory manager functions are too, need to link back to the LabVIEW core that called the according C code directly or indirectly. This is done in the labview.lib file that is linked into every CIN but there is a potential problem for LabVIEW DLLs, since the DLL is invoked by a non-LabVIEW process and that DLL only indirectly links and loads the LabVIEW runtime engine in which the LabVIEW VIs inside the DLL are called.

I haven't understood the exact issues entirely but in newer LabVIEW distributions there is a labviewv.lib which might solve this problem when you make sure to link your CIN with this file instead of the standard labview.lib file.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 3 of 5
(3,679 Views)

Thanks,

I'll try linking the CIN using labviewv.lib from the current version of labview to see if this resolves the issue.

0 Kudos
Message 4 of 5
(3,671 Views)

Problem solved.  The original code resource was built against Labview 6.1.  Once I figured out how to do it, I recompiled the C code against the Labview 8.2 CINTOOLSDIR using the existing LVM (labview make file).  After reloading the code resource to the CIN node, I rebuilt the shared library and the new DLL loads without errors.

I could not see how to explicitly link Labviewv.lib instead of Labview.lib, but it seems this is somehow handled automatically.

Thanks to rolfk for pointing me in the right direction.

0 Kudos
Message 5 of 5
(3,658 Views)