Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Interfacing with a VC++ Class in LabView

Hello all, 
 
  I have developed a Visual C++ DLL that will be used in one of our LabView projects. The Visual C++ project has two classes that perform the duties needed. The interface methods for the class have been made public so they are accessible. There are also two function with are essentially procedural C functions for calculating the CRC for messages. When we attempt create an interface to the DLL using the "Call Library Function Node" the "Call Library Function" window only shows the two procedural C function calls that were declared as follows
 
  __declspec( dllexport ) uint16 __stdcall ComputeCRC16( uint8* dataPtr, uint32 length );
  __declspec( dllexport ) bool __stdcall IsCRC16Valid( uint8* dataPtr, uint32 length );
 
For the class that I would like to export  I declared it as follows

class __declspec(dllexport) LRUInterface
{
  // ...
}

  I would assume that LabView would be able to access the class, instantiate an object then access the methods, but it just doesn't seem to work. How do I declare the class properly so LabView will be able to use the DLL correctly?
 
Mark
0 Kudos
Message 1 of 5
(4,544 Views)
LabVIEW cannot call C++ class methods and properties from a DLL directly using the call library node. You will need to export wrapper C Style functions (functions exported with extern "C") to be able to use them with the call library node. The extern "C" statement is required to instruct the VC++ compiler to not mangle the exported function names, which is what a C++ compiler does by default.
Bilal Durrani
NI
0 Kudos
Message 2 of 5
(4,530 Views)
An alternative approach is create a COM-based DLL.  This approcah can provide object-oriented design for your DLL routines, where as C-style DLL can not.  LabVIEW 6.0 or later supports COM client capabilities.
 
There are two ways to create a COM DLL by VC++ - 1)MFC-based and 2)ATL-based.   Recommended is ATL-based because it is lighter than MFC and rich Class Wizard support is provided for development time in VC++.
0 Kudos
Message 3 of 5
(4,515 Views)

hello

 

plz tell me how to send a new thread on the forum.

I am new to this website.

0 Kudos
Message 4 of 5
(4,482 Views)
suboeta,

  I assume you are referring to starting a new topic thread within the NI Discussion Forums. I am fairly new to this forum also, but what I did was navigate to the most appropriate forum for my question then clicked on the "New Message" button which is to the right of the "Board Options" button.

  After looking at the forums it does appear that you have determined how to post a new topic.

  I do need to take the time to properly thank both bilalD and Makoto for their responses. In the end I converted the C++ code to a procedural C style. The library does appear to be working fine at the moment.

Mark
0 Kudos
Message 5 of 5
(4,471 Views)