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"
long avg_num(float a[], long size, float *avg);
long avg_num(float a[], long 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 no header files. 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. In another instance, a project might need to include extcode.h, the header file for the 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 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 cintools directory of your LabVIEW installation. 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.