LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What to put in preprocessor definitions in Import Shared Library Wizard

Solved!
Go to solution

Hello,

 

I have the same header file shown in the following webpage (except for the KeyGeneration.cpp portion at the end).

 

https://cboard.cprogramming.com/c-programming/121725-reg-problem-creating-dll.html

 

I have a DLL file that generates a key array from a seed array input. I tried using the Import Shared Library and I got the following message. It seems I have to put something in the preprocessor definitions.

 

1.png

 

Any pointer would be appreciated.

0 Kudos
Message 1 of 9
(3,497 Views)

@Chickentree wrote:

Any pointer would be appreciated.


We dont use pointers in LabVIEW :). All jokes aside, can you post the .h file so I can take a look.

Is the DLL just the single function you mentioned, or is there more?

 

0xDEAD

0 Kudos
Message 2 of 9
(3,475 Views)

deceased wrote:

 

We dont use pointers in LabVIEW :). All jokes aside, can you post the .h file so I can take a look.

Is the DLL just the single function you mentioned, or is there more?


Hello, deceased. Here is the h file. It seems the DLL has that one function: GenerateKeyEx(). 

 

Thanks.

0 Kudos
Message 3 of 9
(3,454 Views)

Any knowledge of how big the seed array and output array need to be?

I can make something for you to test but you need to preallocate these buffers in LV.

 

Best regards,

 

0xDEAD

0 Kudos
Message 4 of 9
(3,439 Views)

@deceased wrote:

Any knowledge of how big the seed array and output array need to be?

I can make something for you to test but you need to preallocate these buffers in LV.


2.png

 

Thank you for the help!

0 Kudos
Message 5 of 9
(3,429 Views)
Solution
Accepted by Chickentree

This would be a possible implementation for this function.

Generate Key.png

While the import library wizard can be helpful it can not cleanly handle the array parameters and the related size parameters for this function as it does not know how the different parameters relate to each other. There is even a small chance that I got it wrong, from the limited information available, but I can guess from the names of the parameters how they relate to each other. Letting a computer guess is always like playing vabanque. It may go right but most likely it doesn't and here that means a crash.

 

Note that I connected the return value of the function directly to the error generator VI. This is not really correct as the returned error codes do not map one to one to the LabVIEW used error codes except for code 0 indicating no error!

Rolf Kalbermatter
My Blog
Message 6 of 9
(3,413 Views)

Thank you, rolfk. It works! When I tried configuring each parameter for the Call Library Function Node, I put something wrong.

0 Kudos
Message 7 of 9
(3,402 Views)

Hello, 

 

I tried to use import shared library and i select DLL files and header files then, i click next and i have some issues in preprocess definition and function to convert as error occurred . 

0 Kudos
Message 8 of 9
(72 Views)

You need to understand the API you try to import, how you would have to call it from C and how the header defines are organized in your header file. And you should know a thing or 4 or 5 about how a C compiler handles memory for the various datatypes in general.

The wizard can’t do any of that for you, as it can’t do magic despite its name. If you don’t know about these things you should hire someone who does. Getting anything wrong here not only can but sooner or later make your application crash. That’s ok for one time apps that you just want to run once to see if it works but a major sinkhole for money in any production style app!

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 9
(55 Views)