FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Using C & C++ in LabView

The tutorial, Using Existing C Code or a DLL in LabVIEW, does an excellent job of explaining how to include C functions into a VI via a DLL. I would like to use the same DLL, but with C++ Classes as well. Does anyone know how to do this?

Rob Steele

Message 1 of 10
(57,796 Views)

You will be able to call C++ dlls in LabVIEW, provided that they only use primitive data types. I would recommend you to look at the following resources for detailed information on calling external code in LabVIEW:

1. How Do I Call a Dynamic Link Library (DLL) from LabVIEW?

2. Using External Code in LabVIEW

I hope this helps!

Mehak Dinesh
Applications Engineer

National Instruments

Mehak D.
0 Kudos
Message 2 of 10
(24,035 Views)

My desire was to be able to access a C++ class and it's methods directly. From my reading of the documentation it appears that I can do this by buidling a C wrapper which calls the method I am interested in. Is this correct?

0 Kudos
Message 3 of 10
(24,035 Views)

Yep. You will need to build wrappers

Joel Sumner
NI-Shanghai
0 Kudos
Message 4 of 10
(24,035 Views)

The good news is that I can use my working C and C++ code and call call it from labView. The bad news, is that the C++ code must be wrapped within C functions.

0 Kudos
Message 5 of 10
(24,035 Views)

My goal was to do my vision code and signal processing code through labview and have it give the data to some localization code I wrote in C++. Does this mean I cant use the full capabilities of C++ such as classes and methods?

0 Kudos
Message 6 of 10
(24,035 Views)

You can still use all of your functionality, but how you access is , in my opinion, a little contrived. What I did to use my C++ code was to instantiate the C++ objects in the dllmain. From there I built C wrappers which called my functions. When I had to pass in data structures I had to build C wrappers to handle bundling and unbundling the primitive data types. For me, I was using the functions in the standard template library for sorting that I wanted to continue to use. After i made the committment to use the wrapper functions things went very easy.

One thing I did do was to build vi's that would wrap one or two of the C++ methods. This way I only replicated what looked like standard vi's through my application and I did not have the "Call Library Function Node" directly visible on my 'high level' vi's.

Rob Steele

Message 7 of 10
(24,035 Views)

nice information

0 Kudos
Message 8 of 10
(24,035 Views)

Hey,

I've been taking a programing class (Just BASIC and C++) this past semester.  Where is a good place to start looking for how to code the robot using C++ ?

Thanks,

Davis Catherman

0 Kudos
Message 9 of 10
(24,035 Views)

Thanks

0 Kudos
Message 10 of 10
(24,035 Views)