LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

interface .dll - can I involve some C++ code

Steffen01_0-1732747109303.png

true, on the supplier side its a void function. But in the wrapper I could turn it into an int function or whatever

0 Kudos
Message 21 of 73
(477 Views)

@Steffen01 wrote:

 

true, on the supplier side its a void function. But in the wrapper I could turn it into an int function or whatever


Now you seem to somehow use contradicting reasoning or something.

 

First you say LabVIEW can't call a function with a return value as the one provided by your supplier. When I point out that it can, your supplier function suddenly has no return value!

 

Which is it?

Rolf Kalbermatter
My Blog
0 Kudos
Message 22 of 73
(474 Views)

supplier dll has void functions. But that does not matter to Labview. The wrapper dll talks to the suppler dll. But Labview talks to the wrapper dll. So there could be a different type in the wrapper

0 Kudos
Message 23 of 73
(471 Views)

Just an extra note. You mention C++, and so far you seem to just try to use global functions that are apparently name mangled. That in itself should not pose a problem to call them from the Call Library Node directly. But if you eventually happen to need to interface to classes with virtual functions, you definitely will need a wrapper.

 

See here for an example of how to deal with that.

Rolf Kalbermatter
My Blog
0 Kudos
Message 24 of 73
(452 Views)

its classes. And for the part that I am interested in by the look of it one needs to bundle 3 of them and the output will be a bundle of max, min and current poins, 90 values all up. But I figured if I have to learn C++ from scratch, I start with adding 2 values as an example.

Supplier code is in C++, they supplied an example program, and a header file. So best bet is to do the wrapper in C++ as well. This will take a long time....

Our guys use Python and asked supplier to program them something. Haha. Supplier uses C++ and Labview, they gave me nothing.

And yes, some basic functions in their DLL I can actually access with the wizzard. See post #4. Pretty useless stuff to me, like units are in SI etc. So I know it works as such. Lucky, the old software with SOAP will be around for another 1 year, so I still got some time....

0 Kudos
Message 25 of 73
(442 Views)

@Steffen01 wrote:

its classes. And for the part that I am interested in by the look of it one needs to bundle 3 of them and the output will be a bundle of max, min and current poins, 90 values all up. But I figured if I have to learn C++ from scratch, I start with adding 2 values as an example.

Supplier code is in C++, they supplied an example program, and a header file. So best bet is to do the wrapper in C++ as well. This will take a long time....

Our guys use Python and asked supplier to program them something. Haha. Supplier uses C++ and Labview, they gave me nothing.

And yes, some basic functions in their DLL I can actually access with the wizard. See post #4. Pretty useless stuff to me, like units are in SI etc. So I know it works as such. Lucky, the old software with SOAP will be around for another 1 year, so I still got some time....


You got the important pieces of information AFAIK. It can be taunting of course but if you can work on this in your normal worktime and not as a hobby project, a year should be plenty of time to get this working. Once you got one done, it's mainly a lot of copy and paste and if you feel adventurous you can venture into macro voodoo. It's not trivial but if you have to interface to a lot of similar APIs you can squash a lot of work by spending a bit extra time for smart macros that then can be used to create the nitty gritty details on the fly for the various APIs you need to interface to.

Templates may look tempting when you work in C++, but your API to call from LabVIEW has to be standard C, so you end up having some sort of standard C wrappers around your template wrappers. Usually that is not any improvement.

Rolf Kalbermatter
My Blog
0 Kudos
Message 26 of 73
(478 Views)

this is only for our testrig, mainly for myself. Just makes my life easier.

I guess I can try, if their header file does not cause too much trouble in my C++ compiler, then next step I try in C. From what I understand I need the header and also the suppliers .lib file so Visual Studio finds the entry points of the function. It would not compile my dlls without having the .lib file. Lots more pain ahead. But essentially I just need to tap into one function to get the results I need. But that function is also the end boss of their functions

0 Kudos
Message 27 of 73
(464 Views)

No! If you want to call C++ code you need to use C++. But you want to declare the exported functions in your wrapper as extern “C”.

 

This tells the C++ compiler to not name mangle the function name and not do any other C++ specific things for that function export.

Rolf Kalbermatter
My Blog
Message 28 of 73
(452 Views)

suppose that is this, in the header, make sure functions are not mangled. Because it works ok

Steffen01_0-1732925166355.png

this is the add friends setting, for future readers

Steffen01_1-1732925614505.png

here both functions getting Dll18.dll to add 2 numbers

 

Steffen01_0-1732926277007.png

 

 

Message 29 of 73
(439 Views)

actually there was a mistake, but this works

 

Steffen01_0-1732937026026.png

Steffen01_1-1732937095271.png

 

 

Message 30 of 73
(433 Views)