How to build a CIN code resource (.lsb file)
Overview
This document details the steps necessary to create a CIN code resource (.lsb file) using the following compilers:
Table of Contents
Microsoft Visual C++ v. 5.0 for Win32 platforms
Visual C++ 5.0 has a Custom Build capability that allows you to build CINs from within the Integrated Developer Environment. Complete the following steps to generate the "VI_name.lsb" file (Note LabVIEW must be installed on the computer where you'll be using cintools). 1) Create a DLL project.
- Make a new project by selecting File>>New.
- Specify the type to be "Win32 Dynamic-Link Library."
- Name the project "VI_name", with no spaces, and click OK.
- Select Project>>Add To Project>>Files.
- Go to the cintools directory and select cin.obj, labview.lib, lvsb.lib, and lvsbmain.def
- You can select multiple items by holding down the <Ctrl> button and clicking the items you want. Then click OK.

3) Add your "VI_name.c" file to the project.
- Select Project>>Add To Project>>Files.
- Go to the folder that holds your "VI_name.c" file and select it.
- Click OK.
4) Edit Project Settings.
- Select Project>>Settings.
- Set the Settings For field to All Configurations.
- The remaining sub-steps are all within this panel:
Do not click the OK button until instructed to do so later.
- On the C/C++ tab:
- - Set the Category field to Preprocessor.
- Add the absolute path to your cintools directory in the Additional include directories field. Paths should either be in MS-DOS format or have quotes surrounding the entire path.

Set the Category field to Code Generation.
- -Change the Use run-time library field to Multithreaded DLL.
-Change the Struct member alignment field to 1 Byte.

- On the Custom Build tab, scroll to the right to find the custom build tab.
Fill in the following fields:
| Description: | Fill in a description. |
| Build commands | "<your Cintools path>\win32\lvsbutil" "$(TargetName)" -d "$(WkspDir)\$(OutDir)" |
| Output files | "$(OutDir)$(TargetName).lsb" |

5) Add your code to the VI_name.c file.
- Select the File View tab in the Work Space Window.
- Double click on your VI_name.c file.
- Add your code to the area that says /*ENTER YOUR CODE HERE*/.
- Verify that your code compiles by selecting Build>>Compile VI_name.c
- If your code does not compile, the CIN does not work.
- Debug your code before continuing.
- Select Build>>Build VI_name.dll
- This creates the VI_name.lsb file and places it in:
Program Files\DevStudio\MyProject\VI_name\Debug
- NOTE: There are several warnings produced during the link, but these can be safely ignored.
CodeWarrior for PowerPC platforms
| From the CodeWarrior IDE, select File>>New Project. This brings up a window "New Project." Expand MacOS and C/C++. Select Basic Toolbox PPC. Enter the new project name as VI_name, and save it. CodeWarrior opens the new project VI_name window. There are four folders:
Delete the following items by selecting them and clicking Option-Delete:
Add two files to Mac Libraries by highlighting Mac Libraries and selecting Project>>Add Files. Navigate to the LabView directory and point to the following files:
Point to your VI_name.c file. |
Prepare the CodeWarrior Environment to create the .tmp file:
THIS PART IS CRUCIAL: Change the name projectName.exp to VI_name.exp. In other words, use the same name as the name of your project (in this example it is VI_name). 3. Go to Access Paths. Under User Paths, add the following three directories from LabVIEW directory: If it asks you to save the changes when moving from Access Paths to PPC Target, click Yes or OK. Under PPC Target, make the following settings: 7. Go to Linker>>PPC Linker, and empty the Entry Points, i.e., make the following settings: 9. Close the Basic Toolbox PPC Settings window. If it prompts you to save the changes, click Yes or OK. |
| Create the .tmp file Go to Project, and select Make. (Shortcut is Command-M.) This will create "VI_name.tmp" in the project folder. |
| Build the code resource file under PowerMac Launch lvsbutil.app by double-clicking it. (It is located in the LabVIEW>>cintools folder). Select File>>Convert .tmp File. (Shortcut: Command-K) Select VI_name.tmp that you just created. This will create "VI_name.lsb" in the same folder where you have VI_name.tmp file. |
Gnu C compiler for Solaris platforms
1) Run lvmkmf
After you write the code, run the lvmkmf utility on the c source file.
lvmkmf mycode (no extension!)
If you do include the extension (i.e. `lvmkmf mycode.c`), when you run make, you will get the error
"make: Fatal error: Don't know how to make target `mycode.c.o'"
This creates Makefile, which can be used by make.
2) Edit the Makefile
Change the following lines:
#
# This Makefile was generated automatically by lvmkmf.
#
CC=cc -----> CC=gcc (or g++)
LD=ld
LDFLAGS=-G
XFLAGS=-K PIC -----> XFLAGS=-fPIC
CINDIR=/00/bin/lv501/cintools
CFLAGS=-I$(CINDIR) $(XFLAGS)
CINLIB=$(CINDIR)/libcin.a
MAKEGLUE=$(CINDIR)/makeglueSVR4.awk
AS=as
3) Run make
Run make and it builds a proper lsb file.
Reader Comments | Submit a comment »
.lsb generation in MS VC++ 2008
I have finally managed to generate an lsb.
My command line looks like this:
"C:\Program Files\National
Instruments\LabVIEW 8.5\cintools\lvsbutil"
"$(TargetName)" -d "$(OutDir)"
the $(WkspDir) statement in the -d operator
was not recognised. I have also tested with
both the 8.2 and 8.5 versions of lvsbutil.exe
and only the 8.2 version worked.
- Vince. V.Azorin-Peris@lboro.ac.uk - Apr 1, 2008
Finally got this to work with Visual C++ 6.0
Took me a lot of poking through the
various CIN threads & the comments
here, but I finally got this to work. The
Custom Build command needs the
directory fix (No 'win32' as commented
below) and needs spaces between
each set of quotes, which is not very
clear. My Commands looked like this:
"C:\Program Files\National
Instruments\LabVIEW 8.5
\cintools\lvsbutil" "$(TargetName)" -
d "$(WkspDir)\$(OutDir)"
This was after copying the 8.2
lvsbutil.exe file over the 8.5 one as
outlined in another thread. I never tried it
with the 8.5 version.
- tatwood@redshiftsystems.com - Jan 24, 2008
Issue with Custom Build Pane and Visual Studio Workspaces vs Projects
Using lvsbutil from the command actually fix
the issue, but I've found that the source of
this issue could reside in an invalid
command in the custom build pane: the given
syntax from "How to build a CIN code
ressource (.lsb file)" from "Build
commands : "
- Apr 24, 2006
This application note does not work.
I kept getting an error in my compiler as
follows.
Linking
Running LVSB Utility
The system cannot find the path specified.
Error executing c:\windows\system32\
cmd.exe.
The problem is that in the Build Commands
the path is wrong. \win32 should be omitted.
For most people this directory does not
reside in the labview directory.
- James Photis, Analog Devices. james.photis@analog.com - Apr 7, 2006
The file lvexcode.pdf (supplied by installer)
does not indicate that you need quotation
marks around the path to lsbutil.exe; where
as this file does. It's the differnce
between compliling and generating an error.
- Oct 28, 2005
Labview 7 and VC++ 6.0
This seems to be a bit out of date. Using XP, labivew 7.1
full, and visual C++ 6.0, I can't get the above to work.
Just getting recurrent error:
error exceuting c:\windows\system32\cmd.exe
- Dec 1, 2004
Solution for vs.net (2003)
Needs to be updated for vs .net (2003) in
such a way:
you need to set "Linker\Input\Module
Definition File" to "
- Mikhail Zakharov, Drexel University. mzu@drexel.edu - Nov 24, 2004
this example don´t function in win XP
Dear sir
This example don´t function in win XP
because create this dll dont compile.
- Jorge Higuera, UIS. maepe3@uis.edu.co - Nov 3, 2003
Need to update for version 2003!
This need to be updated with instructions
for the latest version of Visual
C++.net
(version 2003)!
- Sep 9, 2003
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
