National Instruments 320685D-01 ユーザーズマニュアル

ページ / 211
Chapter 7
Creating and Distributing Standalone Executables and DLLs
©
 National Instruments Corporation
7-15
LabWindows/CVI Programmer Reference Manual
Forcing Modules that External Modules Refer to 
into Your Executable or DLL
In the LabWindows/CVI development environment, external modules can link to modules in 
the Instrument and Library menus regardless of whether you refer to them elsewhere in 
your project. However, when you create a standalone executable, LabWindows/CVI includes 
in the executable only modules that your project refers to directly. If an external module refers 
to modules not included in the executable, calls to 
RunExternalModule
 or 
GetExternalModuleAddr
 on that external module fail.
To avoid this problem, you must force any missing modules into your executable or DLL. 
You can do this when you create your executable or DLL by using the Add Files To 
Executable 
or Add Files To DLL button to display a list of project 
.lib
, project 
.a
Instrument, and Library files. Select the files you want to include in your executable or DLL. 
If you select a 
.lib
 or 
.a
 file, it is linked in its entirety.
Alternatively, you can link modules into your executable or DLL by including dummy 
references to them in your program. For instance, if your external module references the 
functions 
FuncX
 and 
FuncY
, include the following statement in your program:
void *dummyRefs[] = {(void *)FuncX, (void *)FuncY};
Using LoadExternalModule on Files in the Project
You can call 
LoadExternalModule
 on files listed in the project. You must pass the simple 
filename to 
LoadExternalModule
. However, when you create an executable or DLL from 
your project, you might have additional work to do:
If you link your executable or DLL in LabWindows/CVI, the following rules apply for 
files listed in the project:
For 
.c
 or 
.obj
 files, everything works automatically.
For 
.dll
 or 
.pth
 files (Windows 3.1 only), refer to th
 section earlier in this chapter.
For 
.lib
 files, by default, Create Standalone Executable File or Create Dynamic 
Link Library only links in the library modules that you reference statically in the 
project. Therefore, you must force into the executable the modules that contain the 
functions you call using 
GetExternalModuleAddr
To force these modules into the executable, include the library file in the project and 
take one of the following actions:
If you want to force the entire library file into the executable, use the Add Files 
to Executable
 button in the Create Standalone Executable File dialog box, or 
the Add Files to DLL button in the Create Dynamic Link Library dialog box.
00ProRef.book : 06chap07.fm  Page 15  Monday, March 9, 1998  3:23 PM