Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Completing the .c File

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);

Required Libraries

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:

  • labviewv.lib for Visual C++
  • labview.sym.lib for Symantec
  • liblvexports.a for Xcode

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:

  • Allocate, free, or resize arrays, strings, or other data structures that are passed into or out of the library from LabVIEW.
  • Work with LabVIEW path data types.
  • Work with file refnums inside the library.
  • Use any of the Support Manager functions.

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.


Resources


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit