11-26-2015 03:08 PM
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?
Solved! Go to Solution.
11-26-2015 04:33 PM
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.
11-26-2015 04:55 PM
This is how my code looks like, is there any problems?
11-26-2015 04:59 PM
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.