Lab::VISA::Installation - Installation guide for Lab::VISA
Lab::VISA has been tested to work on Linux and Windows, both with ActiveState Perl and the Microsoft VC++ Compiler, and Strawberry Perl with the included gcc compiler.
Work with administrator account during installation.
Install VISA (and GPIB drivers) if necessary.
Download current VISA release from NI (tested with 4.4.1, 4.5.0)
Run installer
Check location of visa32.lib (eg. C:\Programme\IVI Foundation\VISA\WinNT\lib\msc\visa32.lib) and remember for later.
Install Microsoft Visual C++ from http://www.microsoft.com/express/Downloads/
From now on run all commandline programs during installation only from the "Visual Studio Command line", which can be found in the Start menu.
Install Perl.
Tested with ActivePerl from http://www.activestate.com/Products/activeperl/index.mhtml
Make sure to include Perl Package Manager.
Make sure to activate the check box to include perl directory in PATH variable.
Install gnuplot (not mandatory)
Download from http://sourceforge.net/project/showfiles.php?group_id=2055 (gp425win32.zip)
Extract and put it somewhere
Add directory containing pgnuplot.exe to path: My Computer => Properties => Advanced => Environment Variables
pgnuplot.exe
Install dependencies of our perl modules. Depending on how familiar you are with the perl infrastructure, the easiest might be to use PPM, the Perl Package Manager included with ActivePerl.
Install Lab::VISA
Unzip/copy sources
In file Makefile.PL adapt the LIBS and INC settings according to your installation (the location looked up above). This is what worked for me:
Makefile.PL
'LIBS' => ['-"lC:\\Programme\\IVI Foundation\\VISA\\WinNT\\lib\\msc\\visa32.lib"'] 'INC' => '"-IC:\\Programme\\IVI Foundation\\VISA\\WinNT\\include"'
You can find the LIBS folder by checking the registry key "InstDir" in folder "HKEY_LOCAL_MACHINE\SOFTWARE\National Instruments\NI-VISA for Windows 95/NT".
Run the following commands in the source directory
perl Makefile.PL nmake nmake install
Have fun!
Strawberry Perl is a Perl distribution for Windows that most closely mimics a Perl installation under Linux. It comes with gcc compiler, dmake and the other relevant tools included.
Lab::VISA should in principle install out of the box with just the command
cpan Lab::VISA
executed on the commandline. Unfortunately there is a bug in ExtUtils::MakeMaker (see here) that prevents this. Two possible workarounds are explained below.
Have Windows and Strawberry Perl installed
Install NI-VISA
Download 361mb file visa462full.exe from NI's website
visa462full.exe
Install only 'Run Time Support' (I chose all items below that; it's not much)
Locate msc version of visa32.lib and visa.h and adjust Makefile.PL. This is what worked for me:
visa32.lib
visa.h
'LIBS' => q("-lC:/Programme/IVI Foundation/VISA/WinNT/lib/msc/visa32.lib"), 'INC' => q("-IC:/Programme/IVI Foundation/VISA/WinNT/include"),
Work around the bug (known to be present in ExtUtils-MakerMaker-6.56)
Option 1: Patch ExtUtils::MakeMaker
Apply the change described at https://rt.cpan.org/Ticket/Display.html?id=49026 to the file Kid.pm of your installation of ExtUtils::MakeMaker
Kid.pm
perl Makefile.PL
Option 2: Edit generated Makefile
If you don't like to modify the installed version of ExtUtils::MakeMaker, you can edit the generated Makefile. These changes will be lost after executing perl Makefile.PL again though. This option is recommended if you just want to install Lab::VISA.
In the generated file Makefile:
Makefile
Find the two lines containing the words EXTRALIBS and LDLOADLIBS. Add the "C:\path\to\visa32.lib" to each of of these lines. On my system they read:
EXTRALIBS
LDLOADLIBS
"C:\path\to\visa32.lib"
EXTRALIBS = "C:\Programme\IVI Foundation\VISA\WinNT\lib\msc\visa32.lib" C:\strawberry\c\lib\libmoldname.a ... LDLOADLIBS = "C:\Programme\IVI Foundation\VISA\WinNT\lib\msc\visa32.lib" C:\strawberry\c\lib\libmoldname.a ...
dmake
dmake install
As a Linux user you will probably be able to figure out things yourself. Here is a rough outline:
Before you start, you must have the VISA library by National Instrument installed. If you plan to use GPIB connections (which is very likely), you must also have the necessary drivers (NI-488.2) for your GPIB adapter card installed. Refer to National Instruments' very good documentation for additional information:
http://digital.ni.com/softlib.nsf/webcategories/85256410006C055586256BBB002C0E91?opendocument&node=132060_US
In file Makefile.PL adapt the LIBS and INC settings according to your installation. This is what worked for me:
'LIBS' => ['-lvisa'], 'INC' => '-I/usr/local/vxipnp/linux/include/',
Then do the usual
perl Makefile.PL make make install
Here is a quick test program that you can run with perl -Mblib test.pl:
#!/usr/bin/perl use Lab::VISA; my ($status, $sesn) = Lab::VISA::viOpenDefaultRM(); printf "status: %x (%s)\n", $status, (($status == $Lab::VISA::VI_SUCCESS) ? "success" : "no success"); print "sesn: $sesn\n"; my ($status, $findList, $retcnt, $instrDesc) = Lab::VISA::viFindRsrc($sesn, "ASRL1::INSTR"); printf "status: %x (%s)\n", $status, (($status == $Lab::VISA::VI_SUCCESS) ? "success" : "no success"); print "findList: $findList\n"; print "retcnt: $retcnt\n"; print "instrDesc: $instrDesc\n"; __END__
(c) 2010,2011 Daniel Schröer, Andreas K. Hüttel, Daniela Taubert, and others. 2012 Andreas K. Hüttel
To install Lab::VISA, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Lab::VISA
CPAN shell
perl -MCPAN -e shell install Lab::VISA
For more information on module installation, please visit the detailed CPAN module installation guide.