LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a dll fio labview


Yesh wrote:

smercurio_fc you have ben of incredible help to me, thanks. When I search

in Ni developer zone or in simply google, many mention that C++

could be called from labview. I donot know, I will dig more into this

tonight.


What that's referring to is that you can write a DLL using Visual C++, but the DLL that gets created must have the symbols exported correctly. C++ "adorns" the names in a manner such that LabVIEW cannot properly call the functions. This is explained in step 3 of this document: http://zone.ni.com/devzone/cda/tut/p/id/3056.

 


You also said that one could create a wrapper if I want to use dll,

 there are some examples but none had clarity. If you have any examples

which could give me a proper idea.


I'm not sure which examples you looked at, but to write a wrapper DLL you are basically going to start by writing a regular DLL. The DLL you write can do whatever you want, including simply calling another DLL. For example, the wrapper DLL could have a static variable that holds the port that was created from the PodConnect function. Your wrapper DLL can have a "PodConnect" function that returns an integer that's just a pass/fail indicator. You can have functions that are called the same as in the PodAPI DLL, but would not have the HPOD *port parameter. Instead, your wrapper DLL would pass the static variable to the PodAPI DLL functions. If you want to access the various parameters of the HPOD structure you would need to write accessor functions for the parameters. 

 


Also if I have a C dll where to I see all the list of functions when I select

it my Call library function node as you said. Are you using the call-Lib-func node

or trying to import them from the library.


Yes, I am. The list of functions are provided from the "Function name" dropdown on the first tab of Call Library Function Node. Unfortunately, when you select the PodAPI DLL, no functions are listed.

 

 

Message 11 of 12
(530 Views)

Did you create that DLL?? I didn't look at the DLL itself when I wrote my first response, only the header file and what I wrote then still stands for whatever DLL library that header file is for. But this DLL does not export any functions although it seems to contain some code.

 

A look at the lib file seems to indicate that something is wrong with this DLL. This lib file is not an import library for the DLL to use when wanting to access that DLL from a C program, but instead seems to be the entire implementation of the functions.

 

So whoever gave you this "DLL" messed up the build of the DLL, by not exporting the functions it contains and/or gave you the compiled object library of his code, which is of no use for LabVIEW. That lib file can only be used by Visual C. To me it looks like someone create a wrapper C file that simply calls te functions in the lib file,and made a DLL project out of that, but completely forgot to make sure those functions get exported from that DLL.

 

Rolf Kalbermatter

Rolf Kalbermatter
My Blog
Message 12 of 12
(518 Views)