Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Labview Code Interface Reference Manual.pdf
Скачиваний:
33
Добавлен:
29.05.2015
Размер:
1.13 Mб
Скачать

Chapter 4 External Subroutines

called, it can store data in a variable that is global to the external subroutine. Other external code modules can call the same external subroutine to retrieve the common data.

You store external subroutines as files, so you have to give each one a unique name. When LabVIEW searches for a subroutine file, it loads the first file it finds that has the correct name.

Note: External subroutines are not supported on the Power Macintosh. The Macintosh OS on the Power Macintosh provides a much cleaner mechanism for sharing code, namely, shared libraries. If you need to share code among multiple CINs on the Power Macintosh, consult your development environment documentation to learn how to build a shared library.

Although external subroutines are supported on Solaris 2 and HP-UX, it is suggested that you use shared libraries instead.

Shared library mechanisms compatible with LabVIEW are available on all platforms. Under Microsoft Windows 3.1, Windows 95, and Windows NT, they are referred to as DLLs (dynamic link libraries). Under UNIX they are referred to as shared libraries or dynamic libraries.

Creating Shared External Subroutines

Normally, when you use a compiler to create a program, the compiler includes the code for all subroutines in a single file called the executable. External subroutines differ from standard subroutines in that you do not compile the code for the external subroutine with the code for the calling subroutine. Instead, your makefile, and consequently the code, indicate that the calling code references an external subroutine. LabVIEW loads external subroutines based on this information and links the calling code in memory, so that the calling code points correctly to the external subroutine.

You need to compile the calling code, even though its subroutines are not all present. LabVIEW must be able to determine that your code calls an external subroutine, find the subroutine, and load it into memory. When the subroutine is loaded, LabVIEW must be able to modify the memory image of the calling code so that it correctly references the memory location of the external code. Finally, LabVIEW may need to create and initialize memory space that the

LabVIEW Code Interface Reference Manual

4-2

© National Instruments Corporation

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