03-02-2009 03:34 AM
I wrote the following C command to pass SCPI commands to Rohde&Schwarz FSL
#define NIVISA_PXI
#include <visa.h>
#define MAX_CNT 200
int main(void)
{
ViStatus status; /* For checking errors */
ViSession defaultRM, instr; /* Communication channels */
ViUInt32 retCount; /* Return count from string I/O */
ViChar buffer[MAX_CNT]; /* Buffer for string I/O */
status = viOpenDefaultRM(&defaultRM);
if (status < VI_SUCCESS)
return -1;
status = viWrite(instr, "*RST", 6, &retCount);
status = viClose(instr);
status = viClose(defaultRM);
return 0;
}
I am getting linker errors. [Linker error] undefined reference to `viOpenDefaultRM@4'
I use Bloodshed Dev C++ . I have included the header files from the VXIPNP folder to the include folder od Dev C++. It had 11 files.it had 4 header files visa.h, visatype.h, vpptype.h and rsfsp.h
Do i need to install any header file or libraries? Please help, this is the first time I am using VISA.H
Solved! Go to Solution.
03-02-2009 04:17 AM
hi rohit_rs,
I recommend you to use the RsSpecAn Instrument driver. There is already an example for LW/CVI on the driver download page available and correct setup ot the development environment is described inside the How To Use pdf file. (all the things you wrote in your post are encapsulated in one call: rsspecan_init(...)) 😉
regards juergen
ps. to your problem: have you "told" your linker where the visa dll is?
03-02-2009 04:22 AM
excuse my ignorance...but i have never worked with .dll in C++ can u please elaborate how do i tell my linker where the 'visa.dll' file is.
Thnks
03-02-2009 07:54 AM
I figured it nw. Thanks a lot
03-07-2009 05:58 AM
03-09-2009 03:07 AM
03-10-2009 01:13 AM
Yes it is libvisa.so for linux.
Regards,
vaibhav
03-12-2009 07:02 AM - edited 03-12-2009 07:04 AM
[root@localhost raavan]# gcc main.c -L /usr/local/lib/libvisa.so
/tmp/ccKHyQta.o: In function `sendscpi':
main.c: (.text+0x2e): undefined reference to `viWrite'
/tmp/ccKHyQta.o: In function `main':
main.c: (.text+0x52): undefined reference to `viOpenDefaultRM'
main.c: (.text+0x99): undefined reference to `viOpen'
main.c: (.text+0xbb): undefined reference to `viSetAttribute'
main.c: (.text+0xd9): undefined reference to `viClose'
main.c: (.text+0xeb): undefined reference to `viClose'
collect2: ld returned 1 exit status
contents of main.c are:
#include "visa.h"
#include "stdio.h"
#include "string.h"
#define MAX_CNT 200
char scpi[50]; /*To store the SCPI commands*/
ViStatus status; /* For checking errors */
ViSession defaultRM, instr; /* Communication channels */
ViUInt32 retCount; /* Return count from string I/O */
ViChar buffer[MAX_CNT]; /* Buffer for string I/O */
void sendscpi (char *s)
{
status = viWrite(instr, (ViBuf)s, strlen (s), &retCount);
}
int main(void)
{
/* Begin by initializing the system*/
status = viOpenDefaultRM(&defaultRM);
if (status < VI_SUCCESS) {
return -1;
}
/* Open communication with TCPIP Device at Primary Addr FSL (192.168.186.107)*/
status = viOpen(defaultRM, "192.168.186.107", VI_NULL, VI_NULL,&instr);
/* Set the timeout for message-based communication*/
status = viSetAttribute(instr, VI_ATTR_TMO_VALUE, 5000);
/* Send SCPI commands for the test case */
sendscpi ("*RST" ) ;
/* Close down the system */
status = viClose(instr);
status = viClose(defaultRM);
return 0;
}
Please help!