LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with IMPORT SHARED LIBRARY wizard

The wizard isn't a "turkey," you're expecting it to do the impossible.

You mean it's impossible for LV to create a DLL and then have LV turn around and import that same DLL?

 

Well, I can do it on the simple case (C=A+B), with a simple CALL LIBRARY node.  

 

But the "wizard" can't do it without a seemingly endless stream of ugly hacks.

 

So, maybe it is impossible.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 21 of 34
(1,722 Views)

I suspect you can get the notifiers to work by typecasting to a U32, but it would be dangerous.

 

No.   As I said earlier, I tried that and it hangs the machine. 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 22 of 34
(1,719 Views)

@CoastalMaineBird wrote:

The wizard isn't a "turkey," you're expecting it to do the impossible.

You mean it's impossible for LV to create a DLL and then have LV turn around and import that same DLL?

 

Well, I can do it on the simple case (C=A+B), with a simple CALL LIBRARY node.  

 

But the "wizard" can't do it without a seemingly endless stream of ugly hacks.

 

So, maybe it is impossible.


Well, again, the issue is that you as the programmer have more information than the header file provides. You know that A and B are 32-bit integers, so you can easily configure the Call Library node appropriately. C has no standardized way to specify an integer of a certain number of bits, so the DLL Builder has to go through some hacks to force the C compiler (assuming you're calling it from C) to use an integer of the correct size, and those hacks become challenges for the DLL import wizard. Yes, NI could possibly modify the import wizard so that it recognized LabVIEW-specific data types, but what would be the point? While I know people do build LabVIEW VIs into DLLs and then call them from LabVIEW all the time, there's a good argument that that's the least-useful situation for the import wizard because you shouldn't need to do this. The root of the problem is the intentionally-vague C standard, but ignoring that, it's equally reasonable to blame the DLL builder instead of the import wizard.

0 Kudos
Message 23 of 34
(1,716 Views)

@CoastalMaineBird wrote:

I suspect you can get the notifiers to work by typecasting to a U32, but it would be dangerous.

 

No.   As I said earlier, I tried that and it hangs the machine. 


I'd be curious to see this code (preferably a snippet as I'm still on LabVIEW 2012). Where does it hang? At the Type Cast to the U32, or when you typecast back to a notifier, or somewhere else? Slight possibility you need to typecast to a 64-bit value, not a 32-bit one; you could check by typecasting to both and seeing whether the values differ. Also could be an endianness issue at the DLL call, if you aren't careful.

0 Kudos
Message 24 of 34
(1,714 Views)

Well, that was the point where I chucked out that project and said "I need to make it work on a simpler VI first".  I don't have that code handy.

 

It hangs on the call to the DLL.  I'm in LV2013-32, so it's unlikely that the LV RefNum was a 64-bit thing.

 

And since I couldn't even get the C=A+B thing to work, either, the whole line of pursuit is a bust.

 

This needs to work where my customer can develop addons. While he's fair at LabVIEW, I don't want him to deal with all this "C" crap.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 25 of 34
(1,708 Views)

CoastalMaineBird wrote:  

While he's fair at LabVIEW, I don't want him to deal with all this "C" crap.


Isn't that why people often choose LabVIEW? 😉

 

For the A+B thing though - if you do want to make the import wizard work, a few quick edits to the header file would do it. Remove the reference to extcode.h, and replace int_32t with int. If you didn't want to do that, you could instead provide a much-reduced extcode.h that simply defined int32_t to int (and whatever other types are needed), and supply that with the unmodified header built by the DLL builder. I haven't tried this second approach, but I suspect it would work.

 

Not that you're going that route, but maybe it's helpful to someone else in a similar situation.

0 Kudos
Message 26 of 34
(1,714 Views)

I used the Import Shared Library Wizard to create the wrapper for my Add DLL in my example. I'd never used it before but I managed to successfully create the wrapper VI without too many troubles.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 27 of 34
(1,803 Views)

What version LabView?

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 28 of 34
(1,797 Views)

2013 - same as the example I gave (which is where I tried it).

 

Building the DLL:

2015-05-14_12-32-41.png

 

Importing:

2015-05-14_12-33-31.png

Include paths and preprocessor definitions were left blank.

2015-05-14_12-34-22.png

 


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 29 of 34
(1,787 Views)

Well, it's academic at this point, but I do wonder why.

Is your header different from mine (shown in the pic above)?

Did your header include a request for EXTCODE.h?

If so, where did it find it?

Did you have to point out the path yourself?

 

Like I said, it's academic, so ignore if you're not in academic mode.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 30 of 34
(1,779 Views)