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

Example: Building a Shared Library

LabVIEW 8.5 Help
August 2007

NI Part Number:
371361D-01

»View Product Info

The following example uses existing VIs to step through the tasks for building a shared library with the Application Builder.

Complete the following steps in each task to create the LabVIEW project for the shared library build specification, configure the build specification, and build and run the shared library.

Note  The LabVIEW Professional Development System includes the Application Builder. If you use the LabVIEW Base Package or Full Development System, you can purchase the Application Builder separately by visiting the National Instruments Web site.

Preparing the LabVIEW Project

Note  You must have a project open and saved to configure a build specification. If you created a project for the application or source distribution examples, you can open and use the same project.
  1. Select File»New Project to create a project.
  2. Right-click My Computer and select Add»Folder (Snapshot) from the shortcut menu to add a directory of files to the project as a folder. Navigate to and select the labview\examples\Application Builder directory, which contains the VIs and support files you need to build the shared library.
  3. Click the Current Folder button to add the directory to the project. The Application Builder folder appears under My Computer in the Project Explorer window.
  4. Save the project as TutorialProject in a new directory named AB Tutorial.

Configuring the Build Specification

  1. From the Project Explorer window, right-click Build Specifications and select New»Shared Library from the shortcut menu to display the Shared Library Properties dialog box. If you previously hid Build Specifications in the Project Explorer window, you must display the item again to access it.
  2. Complete the following steps on the Information page of the dialog box.
    1. Enter Tutorial-sharedlib in the Build specification name text box. The text box contains the name of the shared library build specification that appears under Build Specifications in the Project Explorer window.
    2. (Windows) Enter Tutorial-sharedlib.dll in the Target filename text box. The text box contains the filename on disk for the executable file. (Mac OS) Enter Tutorial-sharedlib.framework. (Linux) Enter Tutorial-sharedlib.so.
    3. Click the Browse button next to the Destination directory text box and navigate to the AB Tutorial directory. Create a subdirectory named SharedLib. Double-click the SharedLib directory and click the Current Folder button to select it. When you build the shared library, the files appear in this directory.
  3. From the Category list on the left, click Source Files to display the Source Files page, which contains settings you can use to specify which files are included and how they are included in the shared library. Complete the following steps on the dialog box page.
    1. From the Project Files tree, click the Application Builder folder to expand it. Select AB Tutorial MeanMedianMode.vi. Click the Add Item arrow button next to the Exported VIs listbox to add the VI to the listbox and display the Define VI Prototype dialog box. LabVIEW exports VIs you add to the Exported VIs listbox so you can send and return values to and from the shared library.
    2. Complete the following steps from the Define VI Prototype dialog box.
      1. Click the return value parameter in the Parameters listbox. Verify that the Function Prototype description begins with void.
      2. Verify that the Parameters listbox includes an input named Array and outputs named mean, median, and mode.
      3. If the function does not contain these parameters, click the blue Add Function (+) button to add the parameters and set the values to input or output.
      4. Click the OK button to save the configuration settings and close the Define VI Prototype dialog box.
    3. From the Project Files tree, select AB Tutorial StndDev.vi. Click the Add Item arrow button next to the Exported VIs listbox to add the VI to the listbox and display the Define VI Prototype dialog box.
    4. From the Define VI Prototype dialog box, complete the steps listed above for the AB Tutorial MeanMedianMode.vi, but with different parameters. Verify that the Parameters listbox includes an input named Array and an output named standardDeviation.
    5. From the Project Files tree, select AB Tutorial Histogram.vi. Click the Add Item arrow button next to the Exported VIs listbox to add the VI to the listbox and display the Define VI Prototype dialog box.
    6. From the Define VI Prototype dialog box, complete the steps listed above for the AB Tutorial MeanMedianMode.vi, but with different parameters. Verify that the Parameters listbox includes an input named Array and an output named HistogramOut.
  4. From the Category list, click Destinations, Source File Settings, Advanced, Additional Exclusions, Version Information, and Run-Time Languages to explore the settings you can configure in a build specification. For this exercise, do not change the settings on these dialog box pages.
  5. From the Category list, click Preview to display the Preview page. Click the Generate Preview button to view a preview of the files that the Application Builder creates when you build the shared library. You can use this preview to verify that the Application Builder will create the files you want in the directories you want. You can correct errors before you build the shared library.
  6. Click the OK button to close the dialog box and update the project with the build specification settings. The Tutorial-sharedlib build specification appears under Build Specifications in the Project Explorer window.

Building the Shared Library

  1. Save the project. LabVIEW does not save build specifications settings on disk until you save the project.
  2. Right-click the Tutorial-sharedlib build specification and select Build from the shortcut menu to build the shared library. A dialog box displays the progress of the build. When the dialog box displays the build complete message, click the Done button.
  3. Navigate to the AB Tutorial\SharedLib directory. The directory should contain the shared library file Tutorial-sharedlib.dll, the file Tutorial-sharedlib.h that contains parameter prototypes for the shared library functions, the LabVIEW configuration settings file Tutorial.ini, and the data directory, which contains the support files for the shared library.

You can call the shared library from a number of programming languages, including LabVIEW and C.


Resources


 

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