Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

Completing the .c File

LabVIEW 2013 Help

Edition Date: June 2013

Part Number: 371361K-01

»View Product Info

After you build a function prototype to build a shared library from a text-based programming language, 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];



return (1);

*avg = sum / size;

return (0);

Required Libraries

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 labviewv.lib library file in the compiled project. This file appears in the labview\cintools directory.

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 LabVIEW Manager functions for more information about the manager functions.

After you complete the .c file, build the library project in an external IDE.


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