How to build a CIN code resource (.lsb file)

Publish Date: Nov 29, 2018 | 42 Ratings | 2.88 out of 5 | Print | 10 Customer Reviews | Submit your review

Overview

This document details the steps necessary to create a CIN code resource (.lsb file) using the following compilers:

Table of Contents

  1. Microsoft Visual C++ v. 5.0 for Win32 platforms
  2. CodeWarrior for PowerPC platforms
  3. Gnu C compiler for Solaris platforms

1. 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.

  1. Make a new project by selecting File>>New.
  2. Specify the type to be "Win32 Dynamic-Link Library."
  3. Name the project "VI_name", with no spaces, and click OK.

2) Add CIN objects and libraries to the project.

  1. Select  Project>>Add To Project>>Files.
  2. Go to the cintools directory and select cin.obj, labview.lib, lvsb.lib, and lvsbmain.def
  3. 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.

  1. Select Project>>Add To Project>>Files.
  2. Go to the folder that holds your "VI_name.c" file and select it.
  3. Click OK.


4) Edit Project Settings.

  1. Select Project>>Settings.
  2. Set the Settings For field to All Configurations.
  3. 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.

  1. Select the File View tab in the Work Space Window.
  2. Double click on your VI_name.c file.
  3. Add your code to the area that says /*ENTER YOUR CODE HERE*/.
  4. Verify that your code compiles by selecting Build>>Compile VI_name.c
  5. If your code does not compile, the CIN does not work.
  6. Debug your code before continuing.

6) Generate the Code Resource File.

  1. Select  Build>>Build VI_name.dll
  2. 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.

Back to Top

2. CodeWarrior for PowerPC platforms

Create the project file


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:
  • Sources
  • Resources
  • Mac Libraries
  • ANSI Libraries

Delete the following items by selecting them and clicking Option-Delete:
  • ANSI Libraries
  • Resources
  • SillyBalls.c (under the Sources folder)

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:
  • cintools:Metrowerks Files:PPC Libraries:CINLib.ppc.mwerks
  • cintools:PowerPC Libraries: LabVIEW.xcoff
Add your VI_name.c file to Sources by highlighting Sources and selecting Project>>Add Files.
Point to your VI_name.c file.
Prepare the CodeWarrior Environment to create the .tmp file:
1. Make a copy of projectName.exp from LabVIEW\cintools\Metrowerks Files\PPC Libraries, and paste it into the directory where you saved your CodeWarrior project file.
In this directory you should also have the following files:
  • VI_name (Code Warrior project file)
  • VI_name.c
  • VI_name Data (CodeWarrior creates this automatically.)
  • projectName.exp.

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).
2. Go to Edit>>Basic Toolbox PPC Settings. The window should display Target, Language Settings, Code Generation, Linker, and Editor with their sub items.

3. Go to Access Paths. Under User Paths, add the following three directories from LabVIEW directory:
  • cintools: Files:PPC Libraries:
  • cintools:Metrowerks
  • cintools:PowerPC Libraries:
4. Go to PPC Target.
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:
  • Project Type: Shared Library
  • File Name: Test.tmp
  • Creator: LVsb
  • Type: .tmp
5. Go to C/C++ Language under Language Settings. Again, if it asks you to save the changes, click Yes or OK. Under this section, make the following two settings:
  • Source Model: Apple C
  • Prefix File:

    Note: You need to EMPTY the Prefix File section.
6. Go to PPC Processor under Code Generation. Set Struct Alignment to 68K.

7. Go to Linker>>PPC Linker, and empty the Entry Points, i.e., make the following settings:
  • Initialization:
  • Main:
  • termination:
8. Go to Linker>>PPC PEF and set Export Symbols to Use ".exp" file.

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.

Back to Top

3. 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.

Back to Top

Customer Reviews
10 Reviews | Submit your review

CIN generation wizard  - Dec 22, 2008

CIN generation wizard (VS.2003, VS.2005) is available at http:// code.google.com/p/ cinwizardvs2003labview/

.lsb generation in MS VC++ 2008  - Apr 1, 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.

Finally got this to work with Visual C++ 6.0  - Jan 24, 2008

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.

Issue with Custom Build Pane and Visual Studio Workspaces vs Projects  - Apr 24, 2006

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 : "<your Cintools path>\win32 \lvsbutil" "$(TargetName)" -d "$(WkspDir) \$(OutDir)" do not take in account the possibility that users created an empty (common) workspace where they can insert projects. The command line has to be modified accordingly; e.g.: "<your Cintools path>\win32\lvsbutil" "$(TargetName)" - d "$(WkspDir)\project_name\$(OutDir)".

  - Apr 7, 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.

  - Oct 28, 2005

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.

Labview 7 and VC++ 6.0  - Dec 1, 2004

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

Solution for vs.net (2003)  - Nov 24, 2004

Needs to be updated for vs .net (2003) in such a way: you need to set "Linker\Input\Module Definition File" to "<My CINTOOLS DIR>\win32\lvsbmain.def".

this example don´t function in win XP  - Nov 3, 2003

Dear sir This example don´t function in win XP because create this dll dont compile.

Need to update for version 2003!  - Sep 9, 2003

This need to be updated with instructions for the latest version of Visual C++.net (version 2003)!

View more reviews

Bookmark & Share


Ratings

Rate this document

Answered Your Question?
Yes No

Submit