Rebuilding an IVI Specific Driver in Microsoft® Visual Studio® 2010

Updated May 10, 2018

Reported In

Other

Primary Software: Instrument Drivers/IVI>>IVI Compliance Package
Primary Software Version: 2.0
 

Issue Details

I have downloaded an IVI specific driver from NI's Instrument Driver Network and now I would like to rebuild the driver DLL using Microsoft® Visual Studio® 2010. How do I do this?

Solution

To rebuild an IVI specific driver using Microsoft® Visual Studio® 2010, complete the following steps:
  1. First ensure that IVI Compliance Package (ICP)NI-VISA, Visual Studio 2010 and your IVI specific driver of interest are installed on your machine.
  2. Launch Visual Studio and go to File»New»Project...
  3. Select Win32 Project under Installed Templates»Visual C++»Win32. Give the project a name and select OK.
  4. Select Next to continue to the second screen of the Win32 Application Wizard.
  5. Change the Application Type to DLL and click Finish.
Now that our DLL project has been created, we will now need to change some project settings to ensure that Visual Studio can find all of the necessary .lib and .h files for ICP, NI-VISA, and our IVI specific driver that will be needed in order to build the solution.
  1. Right-click on your project in the Solution Explorer window and select Properties
  2. Go to Configuration Properties»VC++ Directories»Include Directories and add the two directories below:
    - C:\Program Files\IVI Foundation\IVI\Include
    - C:\Program Files\IVI Foundation\VISA\WinNT\Include
  3. Go to Configuration Properties»VC++ Directories»Library Directories and add the two directories below:
    - C:\Program Files\IVI Foundation\IVI\Lib\msc
    - C:\Program Files\IVI Foundation\VISA\WinNT\lib\msc
  4. Finally, Go to Configuration Properties»Linker»Input»Additional Dependencies and add the three files below:
    "<specificdriverprefix>.lib"
    "ivi.lib"
    "visa32.lib"
With our project settings configured, we now need to copy the IVI specific driver source into the project and remove any function references that aren't inherently supported by Visual Studio.
  1. Delete the contents of your <projectname>.cpp file and replace the contents with the contents of IVI specific driver DLL source file located here: 
    C:\Program Files\IVI Foundation\IVI\Drivers\<specificdriverprefix>\<specificdriverprefix>.c
  2. Locate the other #includes near the top of the source file and add this code: #include "stdafx.h" in order to allow for precompiled headers. Also comment out the includes for either <formatio.h> or <ansi_c.h> as both of these are LabWindows/CVI-specific libraries that will not be used. 
  3. As a result of commenting out of the above .H files, we will also need to replace a few CVI-specific functions with general ANSI C functions that are completely compatible with all existing input parameters:
    1. All instances of the Scan function should be replaced with sscanf
    2. All instances of the Fmt function should be replaced with sprintf
  4. Finally, build your solution by going to Build»Build Solution

Additional Information

If you receive error C2664 relating to the converting of const char[] to ViBuf then you might need to explicitly cast the const char[] to the ViPBufFor the Fluke 45 IVI specific driver, for example, the code would change from
viCheckErr( viWrite (io, "*TRG;", 5, VI_NULL));
to
viCheckErr( viWrite (io, (ViPBuf)"*TRG;", 5, VI_NULL)); 
 
This rebuilt DLL should now contain any changes that were made to the IVI specific driver source. Always check the DLL modified date to ensure that you have the correct file.

WAS THIS ARTICLE HELPFUL?

Not Helpful