ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with Simple C code with Labview

Hi,

 

I need a simple step by step hints on interfacing C with Labview.

 

I have LabWindows/CVI 2009, and Labview 2009, and the help is a little confusing.

 

As an example, I have a simple C code that ask the user to input 2 numbers, and the result is to add the two numbers.

 

So instead of the prompt, I want to have two controls for the input, then an indicator for the output.

 

Most importantly, I want to use the C code for the summation, not the LabVIEW.

 

In summary, I want to know how I can use C source code, and integrate it into my LabVIEW.

 

 

#include <stdio.h>

int main(void) {
  int first, second; total;

  scanf("%d %d", &first, &second);
  
  total = first + second;


}

This simple C code will take two inputs 'first', 'second', and the sum will be in the variable 'total'.

 

I am new to LabWindows.

If I have a C source code, can I get a dll using Labwindows, then use the call library function node.

 

Thanks

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

That code you have isn't DLL code. I don't know how LabWindows does it, but most modern IDEs can create a project based on the target type you want. For example, if you wanta DLL it creates the source file with the appropriate entry points. For instance, this KB article [article no longer available] shows a simple DLL's basic code.

 

This tutorial is a step-by-step on configuring the Call Library Function Node to call a simple DLL.

 

You can also see the "Call DLL" example that ships with LabVIEW. Open the Example Finder (Help -> Find Examples) and search for "DLL".

0 Kudos
Message 2 of 2
(2,567 Views)