对于同一个链接器问题,我已阅读所有先前的回复或解决方案。我了解链接器无法访问已定义函数的库文件,但我仍然无法解决它!
错误:
1>trial_12th.obj : error LNK2019: unresolved external symbol _viStatusDesc@12 referenced in function _main
1>trial_12th.obj : error LNK2019: unresolved external symbol _viClose@4 referenced in function _main
1>trial_12th.obj : error LNK2019: unresolved external symbol _viRead@16 referenced in function _main
1>trial_12th.obj : error LNK2019: unresolved external symbol _viWrite@16 referenced in function _main
1>trial_12th.obj : error LNK2019: unresolved external symbol _viOpen@20 referenced in function _main
1>trial_12th.obj : error LNK2019: unresolved external symbol _viOpenDefaultRM@4 referenced in function _main
1>C:\Users\41kchoudhary\Documents\Visual Studio 2010\Projects\trial_12th\Debug\trial_12th.exe : fatal error LNK1120: 6 unresolved externals
我正在尝试从混合信号示波器发送和接收数据。在这样做时,我需要使用使用 Microsoft Visual Studio C++ 定义的预定义命令/函数来编写一个 .cpp 文件。我已经阅读了使用这些命令的用户手册,并且我还拥有实现它所需的头文件和库。
我正在使用以下代码:
#include <visa.h>
#include "stdafx.h"
#include <stdio.h>
#include <memory.h>
int main(int argc, char* argv[])
{
ViSession rm = VI_NULL, vi = VI_NULL;
ViStatus status;
ViChar buffer[256];
ViUInt32 retCnt;
// Open a default session
status = viOpenDefaultRM(&rm);
if (status < VI_SUCCESS) goto error;
// Open the GPIB device at primary address 1, GPIB board 8
status = viOpen(rm, "USB::0x0699::0x0377::C011104::INSTR", VI_NULL, VI_NULL,
&vi);
if (status < VI_SUCCESS) goto error;
// Send an ID query.
status = viWrite(vi, (ViBuf) "*idn?", 5, &retCnt);
if (status < VI_SUCCESS) goto error;
// Clear the buffer and read the response
memset(buffer, 0, sizeof(buffer));
status = viRead(vi, (ViBuf) buffer, sizeof(buffer), &retCnt);
if (status < VI_SUCCESS) goto error;
// Print the response
printf("id: %s\n", buffer);
// Clean up
viClose(vi); // Not needed, but makes things a bit more
// understandable
viClose(rm); // Closes resource manager and any sessions
// opened with it
return 0;
error:
// Report error and clean up
viStatusDesc(vi, status, buffer);
fprintf(stderr, "failure: %s\n", buffer);
if (rm != VI_NULL) {
viClose(rm);
}
return 1;
}