LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Suggestions for the Best Tool to Make a Quickie Wrapper DLL for Callbacks?

I've got some API callbacks for which I need to make small wrapper functions and bundle them into a DLL.  The structures are too complex for the LabView App-builder to deal with in generating the DLL.
 
Any suggestions for a quick/easy/free/cheap tool to build this DLL? I've got the C-code - just need to compile it into a DLL for the windoze environment.
 
Thanks!
 
 
0 Kudos
Message 1 of 6
(3,214 Views)
Hi Wiredup,
      I think MSVC++ Express (free from MS) will do it.  When creating a project it won't show a DLL option, but once project is created, change Project\Properties\General\Project Defaults\Configuration-Type to DLL.
 
Cheers!


Message Edited by tbd on 02-25-2008 11:39 PM
"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 2 of 6
(3,200 Views)
Or you can use the nmake tool and the compiler that comes with the Express Edition from the command line. I really hated that IDE, so I have my own editor and just typed a makefile that I process with nmake from the shell.

This makefile should work for you (I build my DLL with a similar one)

# Links the DLL
mylib: *.obj
    link /DLL /DEF:module_definition_file /OUT:mylib.dll *.obj
   
# Compiles all the sources into object files
%.obj: %.c
    cl /c %.cpp


I'm not sure if LabView needs the module definition file or not, but you can try without it first.

When you have the IDE installed, you need to execute a batch file called vsvars.bat in order to use the linker and compiler from the command line. This batch should be found from directory ...\VC++_install_dir\Common7\Tools

If you have any questions about this procedure, don't hesitate to ask.

Hopefully this helps.



Message Edited by kaêm on 02-26-2008 08:58 AM
0 Kudos
Message 3 of 6
(3,192 Views)

Thank you kindly for your swift replies. I've ventured into MS Visual C# land to begin this work (trying to avoid too much baggage associated with C++ decorations, etc.). I think I'm about there. I am struggling with one aspect of this wrapper, though:

I need the wrapper to present the proper data types to the caller of the callback. However, once I've generated/converted the supplied data to data types that LabVIEW understands, I need to generate a UserEvent (the data is passed as a flattened string to the UserEvent). When I was using the App Builder to make the callback, this was not a problem. Now, I'm lost as to how to generate a LabVIEW UserEvent from within a C# or C++ environment?  I'll start surfing the boards and see what I can find.

Thanks again for your help.

0 Kudos
Message 4 of 6
(3,178 Views)

Hi Wiredup,

These links may help:

Using Callback Functions to Respond to User Interface Events

http://zone.ni.com/reference/en-XX/help/370051K-01/cvi/cviusing_callback_functions_to_resp/

Responding to Keypress Events on a Control

http://zone.ni.com/devzone/cda/epd/p/id/1979

Recognizing Events Passed from the User Interface to the Program

http://zone.ni.com/devzone/cda/epd/p/id/1871

 

0 Kudos
Message 5 of 6
(3,136 Views)

Thank you. I had not seen that first reference link. It is very helpful.

I'm finding the easiest way to implement this wrapper is to write a C function that is exactly formatted to the structures specified by the API's callback. These functions simply call functions re-format the data into atomic/flattened/byte array structures that the LabVIEW can understand. Once reformatted, a second callback function is called that contains LabVIEW-generated code (like a user-event firing based when data is received). I'm simply using the App. Builder to make this second DLL.

In other words, when the API calls a callback function, the following data flow occurs:

API Function -->>

 C-authored callback function -->> LabVIEW AppBuilder Generated Function  -->> User Event with Flattened String containing data.

Not pretty, but it seems to work!

0 Kudos
Message 6 of 6
(3,105 Views)