LNK Unresolved External Symbol Error When Compiling a DAQmx ANSI C Example

Updated Jan 10, 2023

Reported In

Driver

  • NI-DAQmx

Other

Visual C, Visual C++ .NET

Issue Details

I am compiling a DAQmx ANSI C example in Visual C and receive the following errors for a number of the DAQmx functions I am using:

error LNK2019: unresolved external symbol _[Function Name]@4 referenced in function _main
error LNK2001: unresolved external symbol _[Function Name]@4

Solution

In order to compile any C code that uses DAQmx function you need to link the NIDAQmx.lib library to your project. This is a two step process. First you have to include the library into your project, and second you must include the location of the library to your default library paths. The following steps show how to perform these two tasks:
 
Visual C 6.0
 
  1. Click on Project in the toolbar and select Settings
  2. Click on your project on the left side of the Project Settings window
  3. Click on Link tab on the right side of the Project Settings window
  4. Append the string NIDAQmx.lib to the string in the Object/library modules: textbox
  5. Click on Tools in the toolbar and select Options...
  6. Click on the Directories tab
  7. Select Win32 for the Platform: combo box and Library files for the Show directories for: combo box
  8. Click on the New button and select the directory containing the NIDAQmx.lib file
  9. Click the OK button to save your changes and close the window
 
Visual C++ .NET
 
  1. Click on Project in the toolbar and select [Project Name] Properties...
  2. Click on Configuration Properties >> Linker >> Input
  3. Type the NIDAQmx.lib to the Additional Dependencies text box, do not close the window
  4. Click on Configuration Properties >> Linker >> General
  5. Click in the Additional Library Directories textbox and select the directory containing the NIDAQmx.lib file. 
  6. Click the OK button to save your changes and close the window

Additional Information

By default, the path of the NIDAQmx.lib that you need to use is the following: C:\Program Files (x86)\National Instruments\NI-DAQ\DAQmx ANSI C Dev\lib\msvc