Build and Run ANSI C Based Example of NI Instruments in Visual Studio

Updated May 24, 2024

Environment

Software

  • Microsoft Visual Studio

Driver

  • NI-DAQmx

Programming Language

  • C
  • C++

NI drivers such as NI-DAQmx come with ANSI C example. To run these examples, environment configuration on the integrated development environment (IDE) is needed. This article will use NI-DAQmx's ANSI C example to demonstrate what and how environment configuration needs to be done to execute the example successfully.

  1. Download and install NI-DAQ™mx .
    • Kindly ensure the following option is selected during the driver installation. 
      image.png
  2. Open one of the NI-DAQmx ANSI C examples located at C:\Users\Public\Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C
  3. Acq-Int Clk from Analog In's Measure Voltage will be used for demonstration purposes in this article.
  4. Open VC_Acq_IntClk.vcproj using Visual Studio.
  5. Click OK if you are getting the following pop-up. 
    image.png
  6. Right-click the project and select Properties
    2023-07-12_15h41_26.png
  7. Select VC++ Directories
    image.png
  8. Add the following paths to General>>Include Directories.
    • If 32-bit NI installer is used: C:\Program Files (x86)\National Instruments\Shared\ExternalCompilerSupport\C\include
    • If 64-bit NI installer is used: C:\Program Files\National Instruments\Shared\ExternalCompilerSupport\C\include
  9. Add the following paths to General>>Library Directories.
    • If 32-bit NI installer is used:
      • For Win32 solution platform: C:\Program Files (x86)\National Instruments\Shared\ExternalCompilerSupport\C\lib32\msvc
      • For x64 solution platform: C:\Program Files (x86)\National Instruments\Shared\ExternalCompilerSupport\C\lib64\msvc
    • If 64-bit NI installer is used: 
      • For Win32 solution platform: C:\Program Files\National Instruments\Shared\ExternalCompilerSupport\C\lib32\msvc
      • For x64 solution platform: C:\Program Files\National Instruments\Shared\ExternalCompilerSupport\C\lib64\msvc
  10. Click Apply followed by OK
    image.png
  11. Click Build Solution in the Build toolbar. 
    image.png
  12. Once the build is completed, the application can be found at the location mentioned in the output window. The image below is an example of the location mentioned in the output window. 
    image.png

Image below shown the result of executing the application.
2023-07-12_16h06_52.png