From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

The function in the dll libray cannot be found

Solved!
Go to solution

I'm try to use the function I build in a C++ dll from Labview "Call Library Function", but it cannot find the function name "Add" or "Divide". Attached is my .dll, .cpp files and VIs, could you help me find where the problem is?

Download All
0 Kudos
Message 1 of 4
(3,302 Views)

A C++ class doesn't export anything from a DLL. You need to declare some functions as declspec(dllexport) in order for that function to be accessible through the Call Library Node. However declaring C++ class methods as such is not going to be a good idea. These all expect an implicit pointer to the actual object instance that is not trivial to handle in LabVIEW. And they can't be declared as extern "C" which makes them getting exported with C++ name decoration, so the exported function name is pretty unrecognizable.

Rolf Kalbermatter
My Blog
Message 2 of 4
(3,275 Views)

 

 

This is how my code looks like, is there any problems?

 

Capture1.PNG

Capture2.PNG

0 Kudos
Message 3 of 4
(3,267 Views)
Solution
Accepted by topic author Xinghe.W

The only function exported in your original cpp file is the 

add_num() 

function. Declaring object methods as static doesn't export them. It just creates object methods that do not have an implicit object pointer as first parameter and therefore those functions can not reference object data members (but your class doesn't have any yet).

 

Basically if you intend to make all methods of your class static, use of a class is in fact pretty meaningless. You would be better of with simple standard C functions like your add_num() function is.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 4
(3,261 Views)