LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

loading a very simple .dll using vectors

Dear all,

I'm trying to load a .dll  in labview that I generated from C++ using code::blocks.

This simple .dll is just a test copying a input vector to the output (vector also). 

The process crashes during import.

I attached the .cpp and .h file for information

Are vectors handled in Labview ?

Any help would be very much appreciated here

 

PS : it wouldn't let me attach the .cpp file so I copy past the very simple code here bellow ( the header file is in attachment )

 

#include "mainRItoIR.h"


void DLL_EXPORT testInputOutput(std::vector<double> &output, std::vector<double> input)
{
output = input;
}

 

 

 

thanks so much

Oliver

0 Kudos
Message 1 of 3
(2,675 Views)

You can not pass C++ objects to a Call Library Node function. C++ object ABI are compiler specific so LabVIEW has no way to even try to implement them in a compiler independent manner. Therefore NI never even attempted to do that.

 

You need to pass standard memory pointers to the DLL.

 

void DLL_EXPORT testInputOutput(double *output, double *input, int numElm)
{
      memcpy(output, input, numElm * sizeof(double));
}

 

And you need to preallocate the output array in LabVIEW of course!

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 2 of 3
(2,618 Views)

Hi Rolfk,

Thanks so much for your great help, this saved my life.

 

Thanks again !

Best regards

Oliver

0 Kudos
Message 3 of 3
(2,579 Views)