10-20-2015 05:19 AM
Hi, I made a project in LabVIEW and created a dll from it that should be used in another environment (Visual Studio). I made a VI for each function I needed and connected inputs and outputs to the icon as usual. The problem is that the functions declared in the header file of the dll seem to be wrong.
For example, the VI "white_noise" in the attached image has no input and one output (the array), but in the header file I found this:
void __cdecl White_noise(double noise_array[], int32_t len);
That seems to be a function in which there are two inputs (array and len) and that has no outputs (void).
The same thing happened fot the other functions of my dll... Why? What am I doing wrong?
Solved! Go to Solution.
10-20-2015 06:03 AM
I haven't done any DLLs, but comparing to how you have to call DLLs in LV; could it be that you feed the function the array and integer where you want your answers/that you want updated?
/Y
10-20-2015 06:50 AM
I don't understand what you mean...
I think I follwed correctly the instructions from National Instruments:
http://digital.ni.com/public.nsf/allkb/A3804F88FCDB1E6286257CE00043C1A7
Referring to this article, the controls you connect as inputs will be the input parameters of the function in C++, and the indicators will be the values returned from the function.
My array is an indicator and can only be an output, so it should be the value returned from the function, not an input inside the brakets ()
10-20-2015 06:58 AM
10-20-2015 07:12 AM
Ok, I don't create DLLs from my LabVIEW code but I think it has something to do with passing the array by reference. You need to pass in an array of the correct (or sufficiently large) size and the function overwrites the data in the array and returns it and provides a length parameter so you can trim the variable. You can also pass the array variable by 'handle' which will write the data back to the original variable (i.e. a pointer). (I don't think my definitions here are quite 'correct' but it should be close enough to understand).
The header information comes from this page that maps the VI to the C-function prototype.
The function can't 'return' the array because you need to know the size etc. of the array and provide the data space or array pointer so I think it can only 'return' scalar values.
10-20-2015 10:32 AM
Thank you! So there's no way to obtain an array (of fixed size) of values from a function of a LabVIEW dll and use it in Visual Studio??
10-20-2015 10:52 AM - edited 10-20-2015 10:56 AM
Yes you can! You just can't have it as the 'return' value of the function - you get the data by passing a variable as an argument to the function (which the DLL then fills with data).
There's a bit more information about it here: http://digital.ni.com/public.nsf/allkb/862567530005F09C8625649700587C37
Edit: And here's an example in c++ - http://www.ni.com/example/26518/en/
10-20-2015 10:52 AM