S/W 개발/LabView&CVI2008.03.18 14:17
[원문] http://digital.ni.com/public.nsf/allkb/70995EC2CA1B523386256DD4004F3DE6

Calling a LabVIEW DLL from a CVI or other C/C++ project

Primary Software: LabVIEW Development Systems
Primary Software Version: N/A
Primary Software Fixed Version: N/A
Secondary Software: N/A

Problem: I compiled a DLL in LabVIEW but I can't figure out how to call it from CVI, Visual C/C++, or other Windows development environment.

Solution: When you build a DLL in LabVIEW, three files are created: the DLL file, a LIB file, and an H file (the C/C++ header file). The DLL file contains the functionality that you programmed in LabVIEW, the LIB file contains a stub for loading and calling the DLL function, and the H file contains a function prototype for calling the function that is contained in the LIB file (which ultimately calls the DLL). To use the code in another environment, you can call the DLL directly using LoadLibrary() and GetProcAddress() functions in the Windows SDK or you can link your project with the LIB file and header file so that you simply call the function by name as though it were already in your project. The latter is the easiest and preferred method for most beginning programmers. To do this:

  • Add the LIB file to your C/C++ project.
  • Include the H file at the top of the source file where you want to call your DLL function by using the #include preprocessor directive.
  • Point your compiler to find other LabVIEW .h files like extcode.h, fundtypes.h, and platdefines.h in the C:\Program Files\National Instruments\LabVIEW\cintools subdirectory. These header files define certain types used by LabVIEW and sometimes passed in and out of LabVIEW code depending on your DLL. If LabVIEW is not installed on the development machine, you will need to copy these .h files from the cintools directory to a location where the development computer can find them.
  • Call the function by its name and parameters as specified in the header file.

Note that the LabVIEW runtime engine includes supporting functions that are required for any code built with LabVIEW and used on another computer. The appropriate version of the runtime engine is required to execute a DLL.

Related Links: KnowledgeBase 28185EQO: LabVIEW Run-Time Engine Requirments for DLL Execution

Attachments:

Report Date: 2003-11-04
Last Updated: 2005-11-05
Document ID: 3337DOV4
Posted by 가희나희아빠 희자매(가희나희)아빠
TAG , ,

티스토리 툴바