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

Document Type: Tutorial
NI Supported: Yes
Publish Date: Oct 16, 2006


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links - Products and Services

Using MSVC to Run MATRIXx SystemBuild Models in LabVIEW

2 ratings | 3.00 out of 5
Print

Overview

The Application Note Running MATRIXx SystemBuild Models in LabVIEW/LabVIEW Real-Time describes how a MATRIXx SystemBuild model can be run in LabVIEW. It uses LabWindows/CVI to compile the model into a DLL that can be called from LabVIEW. This is an alternate template that uses Microsoft Visual C++. This allows for linking non ANSI C code.

Differences Between CVI and MSVC Templates

The two methods are very similar, so first refer to the process that uses CVI (linked below). There are only minor difference. The file c_dllsched.tpl is identical.
  • Exported DLL functions: LabWindows/CVI exports the functions that are contained in the header file. For MSVC _declspec(dllexport) is used to export functions in a DLL.
  • Byte Alignment: LabWindows/CVI uses #pragma pack(1) to align on 1 byte. In MSVC the preferred method is to set it in the project.
  • Project File: LabWindows/CVI and MSVC have different project files. A .dsp project file is generated that is compatible with MSVC 6.0. If you are using a different version you may need to create a new project as described in the Creating a New DLL Project section.
After using the template double click the .dsp file to open the project in MSVC. Then choose Build>Build name.dll to build the DLL. The DLL contains the same functions with the same function prototypes, so there are no changes needed in LabVIEW. The examples below use the CVI template, but if a dll is generated using the MSVC template it would work with the same VI.

Download and copy the attached templates to the same folder as the shipping templates for MATRIXx (default location is C:\Program Files\National Instruments\MATRIXx\mx_63.2\case\ACC\templates). The templates depend on the templates that ship with MATRIXx. If the templates are placed in a different folder, then the shipping templates also should be copied to that same folder. These templates are intended for use with MATRIXx 6.3. The file c_dllsched.tpl is identical to that provided in the Running MATRIXx SystemBuild Models in LabVIEW/LabVIEW Real-Time.

 See Also:
Running MATRIXx SystemBuild Models in LabVIEW/LabVIEW Real-Time

Creating a New DLL Project

  1. Launch MSVC.
  2. Choose File>New and Create a Win32 - Dynamic Link Library.
  3. Choose to create a empty DLL project.
  4. Add the .c and .h files to the project by selecting Project>Add to Project>Files.
  5. Go to Project>Settings. On the C/C++ tab choose Code Generation. Set Struct Member Alignment to 1 byte for the project.

Downloads

c_dched.tpl

c_msvcdll.tpl

2 ratings | 3.00 out of 5
Print

Reader Comments | Submit a comment »

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).