运行National Instruments\NI-DAQ\范例\DAQmx ANSI C中的代码,可正常运行,将相应的代码段拷贝到VC工程中,在头文件中包含#include "NIDAQmx.h",编译出现如下链接错误:
Linking...
VoipDlg.obj : error LNK2001: unresolved external symbol _DAQmxClearTask@4
VoipDlg.obj : error LNK2001: unresolved external symbol _DAQmxStopTask@4
VoipDlg.obj : error LNK2001: unresolved external symbol _DAQmxGetExtendedErrorInfo@8
VoipDlg.obj : error LNK2001: unresolved external symbol _DAQmxReadAnalogF64@36
VoipDlg.obj : error LNK2001: unresolved external symbol _DAQmxStartTask@4
VoipDlg.obj : error LNK2001: unresolved external symbol _DAQmxCfgSampClkTiming@32
VoipDlg.obj : error LNK2001: unresolved external symbol _DAQmxCreateAIVoltageChan@40
VoipDlg.obj : error LNK2001: unresolved external symbol _DAQmxCreateTask@8
解决方法为,将NI MAX安装目录下C:\Program Files\National Instruments\Shared\ExternalCompilerSupport\C\lib32\msvc下的三个文件NIDAQmx.lib nisyscfg.lib niSysMon.lib拷贝到当前工程的目录下,然后在project->setting->Link->Object/Library modules中加入这三个文件,重新编译链接即可。