Jump to content

Shared Library (DLL) unfriendly


EJW

Recommended Posts

Attached is a simple project where i try to create a DLL with a 2D array as an input.

When I try to build the DLL and define the prototype, the builder does not seem to recognize a 2D array as an array.

Consequently, if you try to build a test vi and define the prototype manually (using Call Library Function Node), it

really does not like it, (crashes)

The problem appears to be in the builder itself, as it is not recognizing a 2D array.

Anyone with any thoughts to this please respond.

Download File:post-3482-1164909520.zip

Link to comment
I have either really stumped everyone, or no one uses DLLs enough to have an answer ! :headbang:

Your DLL works just fine. You just made a few mistakes when you tried to call it from LabVIEW. First in your build specifications you defined your dll to use standard calling convention and not C convention. However when you call your library you call it using C convetion. Use Standard instead.

Second you should check the function defenition of the created DLL from SharedLib.h. It says that your DLL call is defined as follows:

_2dDLL(TD1Hdl *ArrayIN, TD2Hdl *ArrayOut);

This means that in order to call the DLL from LabVIEW you should define the function prototype properly. Double click on the Call Library Function Node. Select ArrayIN and ArrayOUT parameters separately. For both parameters the Array format should be changed from Array Pointer to Array Handle Pointer. Then it should work properly.

I don't however assume you want to create a DLL from LabVIEW and call it from LabVIEW. There are easier ways to build VIs than that. On the other hand if you want to call your LabVIEW DLL from C, you are on the right track. LabVIEW passes multidimensional arrays as array handles or array handle pointers. Handles are pointers to pointers to array structure. Array structure is a array of long of the size of the array rank defining the dim sizes of each dimension followed by the array data itself. The struct for your case looks like this:

typedef struct {

long dimSizes[2];

double Numeric[1];

} TD1;

typedef TD1 **TD1Hdl;

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.