Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Using External Code in LabVIEW.pdf
Скачиваний:
49
Добавлен:
29.05.2015
Размер:
1.85 Mб
Скачать

Chapter 3

CINs

Microsoft Windows

To build CINs for LabVIEW for Windows, use the Microsoft Visual C++ or Symantec C compilers.

Visual C++ Command Line

This section describes using command line tools in Windows 2000/NT/9x to build CINs.

1.Add a CINTOOLSDIR definition to your list of user environment variables.

(Windows 2000/NT) You can edit this list with the System control panel accessory. For example, if you installed LabVIEW for Windows in c:\labview, the CIN tools directory should be c:\labview\cintools. In this instance, you would add the following line to the user environment variables using the System control panel.

CINTOOLSDIR = c:\labview\cintools

(Windows 9x) Modify your AUTOEXEC.BAT to set CINTOOLSDIR to the correct value.

2.Build a .lvm file (LabVIEW Makefile) for your CIN. You must specify the following items:

name is the name of CIN or external subroutine (for example, mult) .

type is CIN or LVSB, depending on whether it is a CIN or an external subroutine.

!include $(CINTOOLSDIR)\ntlvsb.mak

To define additional include paths for a CIN you must add a CINCLUDES line to the .lvm file, as follows:

CINCLUDE = -Ipathnames

You must include the -I argument on the line and pathnames is the directory where you look for other includes.

If your CIN uses extra object files, you can specify the objFiles option. You do not need to specify the codeDir parameter, because the code for the CIN must be in the same directory as the makefile. You do not need to specify the wcDir parameter, because the CIN tools can determine the location of the compiler.

You can compile the CIN code using the following command, where mult is the makefile name.

nmake /f mult.lvm

© National Instruments Corporation

3-13

Using External Code in LabVIEW

Chapter 3

CINs

If you want to use standard C or Windows libraries, define the symbol cinLibraries. For example, to use standard C functions in the previous example, you could use the following .lvm file.

name = mult

type = CIN

cinLibraries=libc.lib

!include $(CINTOOLSDIR)\ntlvsb.mak

To include multiple libraries, separate the list of library names with spaces.

Visual C++ IDE

To build CINs using the Visual C++ Integrated Development Environment, complete the following steps.

1.Create a new DLL project. Select File»New and select Win32 Dynamic-Link Library as the project type. You can name your project whatever you want.

2.Add CIN objects and libraries to the project. Select Project»Add To Project»Files and select cin.obj, labview.lib, lvsb.lib, and lvsbmain.def from the Cintools\Win32 subdirectory. You need these files to build a CIN.

3.Add Cintools to the include path. Select Project»Settings and change Settings for to All Configurations. Select the C/C++ tab and set the category to Preprocessor. Add the path to your Cintools directory in the Additional include directories field.

4.Set alignment to 1 byte. Select Project»Settings and change Settings For to All Configurations. Select the C/C++ tab and set the category to Code Generation. Select the Struct member alignment tab and select 1 byte.

5.Choose a run-time library. Select Project»Settings and change

Settings for to All Configurations. Select the C/C++ tab and set the category to Code Generation. Select Multithreaded DLL in the Use run-time library control.

6.Make a custom build command to run lvsbutil. Select

Project»Settings and change Settings for to All Configurations. Select the Custom Build tab and change the Build commands field as follows; this code should appear on a single line:

"<your path to cintools>\win32\lvsbutil" $(TargetName) -d

"$(WkspDir)\$(OutDir)"

Change Output file fields to $(OutDir)$(TargetName).lsb.

Using External Code in LabVIEW

3-14

www.ni.com

Chapter 3

CINs

Note The LabVIEW Base Development system can use existing .lsb files, but cannot create new .lsb files. You can create .lsb files in the LabVIEW Full and Professional Development Systems.

Symantec C

Building CINs using Symantec C is similar to building CINs for Visual C++ Command Line. However, you should use smake instead of nmake on your .lvm file.

Solaris 2.x

LabVIEW for Solaris 2.x uses external code compiled in a shared library format. To prepare this library for LabVIEW, use the LabVIEW utility lvsbutil.

The gcc compiler and the Sun Workshop C Compiler are the only compilers tested thoroughly with LabVIEW.

Note LabVIEW 3.0 for Solaris 2.x supported external code compiled in ELF format.

Existing Solaris 1.x and 2.x (for LabVIEW 3.0) CINs do not operate correctly if they reference functions not in the System V Interface Definition (SVID) for libc, libsys, and libnsl. Recompile your existing CINs using the shared library format to make sure your CINs function as expected.

HP-UX and Linux

The gcc compiler is the only compiler tested with LabVIEW.

gcc Compiler

Create a makefile using the shell script lvmkmf (LabVIEW Make Makefile), which creates a makefile for a given CIN. Use the standard make command to make the CIN code. In addition to compiling the CIN, the makefile puts the code in a form LabVIEW can use.

The format for the lvmkmf command follows, with optional parameters listed in brackets.

lvmkmf [-o Makefile] LVSBName

LVSBName is the name of the CIN or external subroutine you want to build. If LVSBName is foo, the compiler assumes the source is foo.c and names the output file foo.lsb.

© National Instruments Corporation

3-15

Using External Code in LabVIEW

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]