To build a shared library from a text-based programming language, you can build a function prototype in LabVIEW and then fill in all the details of the code. When you allow LabVIEW to generate this function prototype, you help ensure that the basic syntax of the code in the shared library is valid. The prototype source file you create is a .c file and contains C declarations for the parameters you want to pass.
Complete the following steps to build a prototype source file, myshared.c.
Open a new, blank VI and save the VI as Array Average. This function will calculate the average of an array of values.
Note The syntax you see in the Function Prototype field is technically correct. However, the .c file that the Call Library Function Node generates is more precise because the first parameter appears as float a[].
Click the OK button to save your settings and close the dialog box.
Notice that the Call Library Function Node icon updates to reflect your settings.
Right-click the Call Library Function Node and select Create C File from the shortcut menu.
Save the file as myshared.c.
Note In this example, you use a .c source file. When you work with C++ libraries, change the extension of the source file to .cpp.
Preventing C++ Name Decoration
Keep the C++ compiler from introducing platform dependence in exported function names through a process called name mangling by using the C++ compiler function export directive, extern "C"{}, in your header file, as shown in the following example code: