LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Questions about creating a DLL in VC++ to be used in labview

Hi there,
I have created a simple DLL in VC++ 2005 so that Labview 8.2 can call a function, I have followed the direction to creat a dll for labview as the link [link removed], but when i use "call library function node" to call the function "Add" ,I can not see any function, anyone can let me know what the problem is? thanks,
 
Mike
 
the following is my code for the DLL,
 
Header file:

// MathFuncsDll.h

namespace

MathFuncs

 

{

 

class MyMathFuncs

 

{

 

public:

 

 

// Returns a + b

 

 

static __declspec(dllexport) double Add(double a, double b);

 

};

}

Source file

// MathFuncsDll.cpp

// compile with: /EHsc /LD

#include

"MathFuncsDll.h"

 

#include <stdexcept>

using

namespace std;

 

namespace

MathFuncs

 

{

 

double MyMathFuncs::Add(double a, double b)

 

{

 

return a + b;

 

}

}

0 Kudos
Message 1 of 2
(2,393 Views)

Hi happybird,

The LabVIEW Call Library Function Node cannot call C++ class methods and properties from a DLL directly.  You will need to export wrapper C Style functions (functions exported with extern "C") to be able to use them with the Call Library Function Node.  The extern "C" statement is required to instruct the VC++ compiler to not mangle the exported function names, which is what a C++ compiler does by default.

I would check out the Using External Code in LabVIEW and Calling Shared Libraries help topics in the LabVIEW Help (Navigate to Contents >> Fundamentals >> Calling Code Written in Text-Based Programming Languages >> Concepts)

Best Regards,

Jonathan N.
National Instruments
Message 2 of 2
(2,380 Views)