How did you build your CIN? One thing to note is that, if you used the LabVIEW 5.0 Manual, there is an error on page 1-30 of the Code Interface Reference Manual.
On page 1-30 of the manual, the final bullet in the Visual C++ IDE section reads:
...change the Build Commands field to
win32\lvsbutil $(Target Name) -d $(WkspDir)\$(OutDir).
There should be double quotes so that the line reads:
...change the Build Commands field to win32\lvsbutil $(Target Name) -d "$(WkspDir)\$(OutDir)".
This error has been corrected on the LabVIEW troubleshooting page for CINs.
Just in case, I will write down instructions for using Visual C++ to build a CIN for LabVIEW:
In order for LabVIEW to be capable of calling compiled functions of C from a running VI, the code must be loaded and unloaded into memory at the same time as the VI code itself. LabVIEW uses object code in the form of a .lsb file which is generated by the C compiler from the C source code using the ntlvsbm.mak file. This ntlvsbm.mak file is included in the CINtools directory in the LabVIEW folder. You also must create another .mak file which includes parameter definitions for the ntlvsbm.mak file and also includes a call to the LabVIEW .mak file.
The generic documentation for CINs only explains how to use them to call C compiled code from a LabVIEW VI. It shows several development environments such as Visual C++, but in essence it only allows the user to create .lsb files out of plain C source code ( .c ) through C compilers on those environments.
The question now is how can I create .lsb files from C++ native source code using a C++ compiler. Furthermore, how can I create a .lsb file from several C++ source code files (.cpp) and make calls to C++ functions from a VI using CINs? The following explains how to do this:
1) Drop a Code Interface Node (from the Advanced Subpalette of the Functions Palette) into the LabVIEW VI. Make sure to wire the inputs.
2) Right-click on the CIN and choose "Create.c File...", then in the file dialog box specify a "name.cpp" file name. (very important: use .cpp extension)
3) Then create a name.mak makefile (text file) and add the following lines :
name=name_of_cpp_file_without_the_extension
type=CIN
cinlibraries=Kernel32.lib
CINTOOLSDIR=path_to_cintools_directory
!include <$(CINTOOLSDIR)\ntlvsb.mak>
4) Go into Visual C++ and File>Open and open the .mak file. You can even Add the name.cpp file to the project to make it easier to edit. Select that name.cpp or open it as a text file in NotePad or and edit the prototypes of the CIN MgErr functions as shown below, adding extern "C" at the beginning of the line. extern "C" CIN MgErr CINRun(float64 *INPUT);3) Select Build.exe to create the "name.lsb" file. To import the .lsb into LabVIEW, right-click on the CIN and choose "Load Code Resource...". Then, choose the name.lsb file and it is ready to run!
If you want to use several C++ source code files with .cpp extensions, then compile them in Visual C++ and link them to name.cpp and create a .lsb by modifying the name.mak as follows:
name=name_of_cpp_file_without_the_extension
otherobj=other_cpp_files_BUT_USING_.obj_extension
type=CIN
cinlibraries=Kernel32.lib
CINTOOLSDIR=path_to_cintools_directory
!include <$(CINTOOLSDIR)\ntlvsbm.mak>
It is very important that you use a list of files with .obj extensions in the otherobj section. For instance, if you want to link a file called myplus.cpp then use the name myplus.obj in the .mak file. This will allow the Visual C++ compiler to create the .obj file out of the .cpp and it will link it to the rest.
To do this you will need to save a second file called ntlvsbm.mak in the Cintools directory under LabVIEW. This file is attached below.
J.R. Allen