LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error while importing dll

Hello All,

 

I m getting below error while converting dll to LabVIEW vis. Can anyone suggest me how to fix this .

1.png

 

0 Kudos
Message 1 of 6
(1,293 Views)

The problem is with your header file.

Open the header file in notepad or word pad and go to line that contains struct usb_relay_device_info EXPORT_API *

just add ; (semicolon) at the end

i believe its a typo mistake

 

Attached file contains the updated header file

 


CLD Using LabVIEW since 2013
0 Kudos
Message 2 of 6
(1,288 Views)

Hi

 

Already there is a semi colon at the end. But still seeing the same error.

 

VipinAMP_0-1640945762197.png

 

0 Kudos
Message 3 of 6
(1,268 Views)

Try like this

struct usb_relay_device_info EXPORT_API *;

usb_relay_device_enumerate(viod);


CLD Using LabVIEW since 2013
0 Kudos
Message 4 of 6
(1,263 Views)

@kartiknattar wrote:

Try like this

struct usb_relay_device_info EXPORT_API *;

usb_relay_device_enumerate(viod);


That's not quite right! The struct part defines the return value of the function so adding the semicolon would be wrong.

 

But the LabVIEW Call Library Node does NOT support returning struct pointers as function return value. That is the problem here and the import library wizard does not try to work around this limitation since it has not really enough information in the header to make this a fail safe operation.

 

Again and again: The Import Library Wizard is despite its name not a magic tool that can create LabVIEW bindings for random C APIs. Part of the C syntax is at best ambiguous and at worst sometimes misleading. The real work has to be done by a real programmer who understands the API he tries to interface to. The basic rule is, if you can't write a error free C program to call those functions you are never going to know if what the Import Library Wizard created is correct or not and it very easily can be mislead by the information in the header for anything but trivial APIs. It's not the Import Library Wizards fault but it is what C syntax allows to do. It was developed to let programmers create efficient working programs by working pretty close to the bare metal of the CPU hardware, not to hold their hands and prevent them to shoot in their own feet if they decide to do so! No wizard can magically change that!

 

It's not that it would be impossible to interface to this function but it is hard and while I can try to explain all the details here, if you don't understand how to call these functions from a C program yourself it would be pretty useless. It basically involves playing a bit of C compiler yourself and create according code on the LabVIEW diagram. There are three cases really:

 

1) The structure itself contains pointers: Difficulty to solve this in LabVIEW is VERY high and impossible if you do not understand C.

 

2) The structure only contains scalars: That is reasonably doable but still requires a bit of C programming knowledge

 

3) The API user doesn't really need to know what is in the structure as he never SHOULD access anything in it directly. This would be proper API design as letting callers directly poke in structures that serve as a sort handle for a resource as here is a big bag of hornets that will sting the API designer and any potential users in the future when this structure will need to be extended to support new hardware, features or options.

 

In this case just create the declaration of all such structure parameters from 

 

struct usb_relay_device_info *

 

to simply

 

 void *

 

or forget about the Import Library Wizard altogether and create the Call Library Node yourself with a return parameter of Integer, Pointer Sized, and all the parameters of functions that accept this parameter as the same.

 

This API chooses the option 1) for this return value, so if you really need this function, fasten your seat belts and start learning about C programming! It's going to be a very rocky ride! The Import Library Wizard won't be able to help you a single yota with this!

Rolf Kalbermatter
My Blog
Message 5 of 6
(1,236 Views)

Hi Kartik and Rolf,

 

Thanks for the your reply. 

 

I am able to communicate with the relay board using below functions,

 

usb_relay_device_open_with_serial_number() - I have the utility provided by relay manufacture where i can get the serial number of each relay board.
 
usb_relay_device_close()
usb_relay_device_open_one_relay_channel()
usb_relay_device_close_one_relay_channel()
usb_relay_device_open_all_relay_channel()
usb_relay_device_close_all_relay_channel()
 
 
So I m not using other functions like,
usb_relay_init(void);
usb_relay_exit(void);
usb_relay_device_enumerate(void);
usb_relay_device_free_enumerate(struct usb_relay_device_info*);
 
-Vipinraj KK
0 Kudos
Message 6 of 6
(1,185 Views)