LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Load a complex dll in Labview

Solved!
Go to solution

Hi guys:

 

  I need to load a dll in labview, the prototype is :

 

long function(const char   a[],
     const double b,               
     const int    c,   
     double d[5][23],)  
     double e[4], 
     );

 

 

 

I set the prototype in labview is:

 

 

uint64_t Function(const CStr a,

const double b,

const int32_t c,

Array2DDouble **d,

double *e);

 

  but the function can't work ,  i guess there maybe some isuue at parameter d , the enclosed file is the config box , 

SpxImage.jpg

Anyone tell me where the problem is?

 

thanks

 

Message Edited by adobefree@gmail.com on 06-05-2010 10:46 PM
0 Kudos
Message 1 of 10
(4,293 Views)

Hi adobefree@gmail.com,

  labview supports only com dlls...Check before using this.

 

 

Thanks and regards,

srikrishnaNF

Regards,
Srikrishna


0 Kudos
Message 2 of 10
(4,278 Views)
yes , i have checked that , it is
0 Kudos
Message 3 of 10
(4,276 Views)

hi, 

 

you can just do a simple check: if you configured your interface node, right-click it and select "Create .c File"...then a header file is created and you can compare your data types in YOUR dll with the ones LabView expects...

 

Also, I don't really know if your char[] is compatible with a CStr..perhaps you can try using a numeric byte of U8 which you can create by typecasting a string to an U8-array (but this is only a guess)

 

good luck

 

christian 


THINK G!! 😉
------------------------------------------------------------------------------------------------
Using LabView 2010 and 2011 on Mac and Win
Programming in Microsoft Visual C++ (Win), XCode (Mac)
0 Kudos
Message 4 of 10
(4,235 Views)

The problem is indeed your parameter d (among possibly other things such as the calling convention, etc).

 

LabVIEW array handles are a specific datatype only meant for LabVIEW or DLLs written to understand LabVIEW datatypes. Your 2D array is certainly not a LabVIEW array datatype but a simple Array Data Pointer. 

 

While you could represent a 2D array in C as an array of pointers to 1D arrays, this is not how it is done for matrix like arrays. Instead a 2D array in C is normally really just a 1D array with x * y number of elements.

 

So configure your d parameter to be a Array Data Pointer with 2 dimensions. And if this is an output parameter (a parameter that is filled in by the function) avoid the next LabVIEW Call Library Node (CLN) beginner problem and initilize the array to be of the right size before passing it to the CLN. While LabVIEW will take care about allocating and resizing arrays as needed inside VIs, it can under no circumstances know how much memory your C function would need and the C function can not allocate LabVIEW compatible memory in any way. So it is your responsibility as programmer to do that explicitedly before passing any array data pointer to a CLN.

 

Same applies of course for parameter e.

 

Also unless your DLL is 64 byte, the long type of the return value of the function never would translate to an int64 datatype (and for Windows 64Bit it is still 32bit, while for most any other 64bit OS it would be indeed 64bit).

 

Don't you love how Microsoft always tends to differ with the rest of the world? Smiley Wink

 

Message Edited by rolfk on 06-07-2010 09:41 AM
Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 10
(4,218 Views)

srikrishnaNF wrote:

Hi adobefree@gmail.com,

  labview supports only com dlls...Check before using this.

 

 

Thanks and regards,

srikrishnaNF


I'm sorry, but LabVIEW supports COM (OLE, ActiveX) DLLs through its ActiveX nodes, .Net assemblies through the .Net nodes and classical DLLs exporting functions through the Call Library Node. Not sure how this would qualify as "only".

Message Edited by rolfk on 06-07-2010 09:38 AM
Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 10
(4,217 Views)
thanks for all of your suggestions , i will try it  , and update the status in time
0 Kudos
Message 7 of 10
(4,167 Views)

i have tried to config the prototype as upfloors:

 

SpxImage.jpg

and also malloc the right memory before pass into CLN

SpxImage2.jpg

 

but still can't work , so i have to change the "d" in c dll definition from d[5][23] to d0[23],d1[23],d2[23]...... , it's ok ,

Is there any suggestion?I do really wana to know , how to pass c type n dimensions array in labview?

Message Edited by adobefree@gmail.com on 06-08-2010 08:48 PM
0 Kudos
Message 8 of 10
(4,140 Views)

This doesn't make sense to me. Maybe it is the C++ declaration (a constant array declaration as function parameter wasn't valid in standard C AFAIK) that means something else than I think it does but in standard C

 

d[5][23] creates an array of 5 * 23 elements (as function parameter it obviously doesn't create that array but make sure the C compiler complains if you pass it anything else).

 

Where I start to wonder is the difference in number of parameters you show in your (presumably dummy) C prototype and in the picture. And of course the two one dimensional arrays after your supposedly not working parameter that are used as output parameter but nowhere allocated in the diagram, or did you use the Array Size parameter in the CallLibrary Node configuration dialog to make sure the are always allocated to a minimum size?  Also a long really really isn't 64 Bit eventhough I'm not sure how that would crash.

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 10
(4,122 Views)
Solution
Accepted by topic author adobefree@gmail.com

Good news. I have fix it

0 Kudos
Message 10 of 10
(3,970 Views)