I am importing a dll functionality in LV using import shared lib tool. I am getting a following problem in exporting dll which are related to callback fucntion or if I am wrong please correct me.
About this problem I can see following callacks in my .h file
I am well famillier with LV development and importing of dll (which are independent of these callback things) but not familer with C++ and I need your help for implementing these callbacks and using them in LV, I am queries about,
Thanks in advacne !
A callback function is a function pointer that is passed to the function. LabVIEW has no way to create a function pointer directly. If it had, the configuration for that would be several times more complicated than the Call Library Node dialog and considering the troubles the Call Library Node dialog already causes most of the people, it is a safe bet that such a configuration option is pretty useless.
So to your questions:
1) you don't. There is nothing in LabVIEW that can represent a function pointer directly and therefore you can not configure the Call Library Node to pass this to the function. The only exception to this is if this callback function parameter can be NULL to disable the callback feature. In that case you configure it as a pointer sized (unsigned) integer and pass a 0 integer constant to it. If NULL is a valid option or if that will simply crash the application trying to call it in that way, should be stated in the documentation to the function.
2) It's a somewhat misplaced naming convention chosen by the LabVIEW developers. While it is technically not wrong it has nothing to do with callback parameters. Instead, that are functions that LabVIEW will call when loading, unloading and aborting the VI that contains such a Call Library Node. The only parameter of these three functions is a data pointer instance that the init function typically initializes, the finish function would clear and deallocate if necessary and the abort function would use to abort any asynchronous operation that may still be going on in the DLL from a call to the actual function configured in the Call Library Node. For that to work you have a special parameter datatype in the configuration dialog called Instance Data Pointer. This is the same pointer that the init, finish and abort functions receive.
If you ever have programmed Windows API from C or a similar programming language you may have come across certain functions that take an LPOVERLAPPED data structure pointer. Overlapped operation is the Windows speak for asynchronous operation where the call to the function returns almost immediately to the caller while the operation is continued in the background and through the data structure pointer the caller can then manage (and sometimes monitor the progress of) the background operation. The LabVIEW Instance Data Pointer is something similar like this LPOVERLAPPED parameter to these Windows APIs.
3) A wrapper DLL is something you write in (typically C or C++ but any language that can generate DLLs and handle function pointers is in principle possible). It provides functions that you can call from LabVIEW and translates various parameter types to the parameters your real DLL needs and then calls the real DLL functions. It can be handy to write such a wrapper DLL for any type of parameter translation but in the case of callback function parameters is more or less unavoidable. And while C(++) itself isn't exactly rocket science it is a very powerful programming language that gives the programmer almost complete control over every aspect of the system and with great power comes great responsibility. In contrast to LabVIEW it is not only easy to create access violations and other nasty bugs that will crash your application, but almost unavoidable during development of such code. And function pointers are one of the more advanced features of C(++). It's one of the things usually handled at the end of a C programming course and since not needed for a lot of programming problems also usually never properly learned by many programmers and eventually forgotten about by most of those who even bothered to try to learn it.
The extra challenge is to translate the callback function call into something that works in LabVIEW. Possibilities are manifold, sometimes there only needs to be a callback function that simply can be passed to the function and does nothing really because you are not really interested in what the callback function is telling you, but the programmer of the DLL did not allow for NULL to be passed to the callback function parameter.
Or it can simply store a status or something in a global variable or a session variable that you manage in the wrapper DLL and that can be queried by another function in your wrapper DLL.
Or the callback function calls the PostLVUserEvent() LabVIEW manager function to generate a user event that the LabVIEW program can then respond to.
If you haven't some serious C programming knowledge, a wrapper DLL without callback function is a pretty hard thing to do, but a wrapper DLL with callback function is going to be your nemesis.