After you build the function prototype, complete the .c file.
The Call Library Function Node generates the following source code skeleton in myshared.c:
/* Call Library Source File */
#include "extcode.h"
int32_t avg_num(float a[], int32_t size, float *avg);
int32_t avg_num(float a[], int32_t size, float *avg)
{
/* Insert Code Here */
}
Replace the /* Insert Code Here */ spacer with the following function code, making sure to place the code within the pair of curly braces:
int i;
float sum = 0;
if(a != NULL)
{
for(i=0; i < size; i++)
sum = sum + a[i];
}
else
return (1);
*avg = sum / size;
return (0);
This simple example requires the extcode.h header file for a few simple data types. extcode.h provides access to a set of LabVIEW manager functions that perform simple and complex operations, ranging from low-level byte manipulation to routines for sorting data and managing memory. When you build more complex shared libraries, you must include header files for all related libraries. For example, a Windows shared library project might need to include windows.h.
When you want to use the LabVIEW manager functions inside a shared library, you must include the following LabVIEW library files in the compiled project:
The preceding LabVIEW library files appear in the labview\cintools directory. Specifically, you need the LabVIEW manager functions if you intend to do any of the following tasks:
Refer to the Code Interface Node functions for more information about the manager functions.
After you complete the .c file, build the library project in an external IDE.