From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VC++ and NI488.2

Hello,

 

I have installed NI488.2 Version 3.1.2.  I am using VC++ 10.0.

 

From the NI-VISA Manual, I have typed out the code below.  When I compile it, I get this error:  error LNK2019: unresolved external error symbol_viOpenDefaultRM@4 referenced in function_main.  This only happens after I include the status = viOpenDefaultRM(&defaultRM); line.  Does anyone know why this is?  I am not sure which library I am missing or how I would link to it.  However, I don't have any of the .obj or .lib files that I read on other forums.  I am also using Windows X 32-bit.

 

#include <stdio.h>
#include <Windows.h>
#include "visa.h"

#define MAX_CNT 200

int main(void)
{

    ViStatus status;
    ViSession defaultRM, instr;
    ViUInt32 retCount;
    ViChar buffer[MAX_CNT];
    
    status = viOpenDefaultRM(&defaultRM);
    if (status <VI_SUCCESS){
        return -1;
    }
            
 
    
}

0 Kudos
Message 1 of 2
(3,927 Views)

It looks like it's a problem with the way you're including visa.h. You'll probably want to reference the copy of visa.h where it was originally installed on your computer with VISA, so that the header file can access any resources it needs that it was installed with.

 

The best way would be to add its folder to your include path in your IDE, and then do:

 

include <visa.h>

 

the other way would be to explicitly use the long path to the original location of visa.h:

 

include "C:\...\visa.h"   (where the "..." is replaced by the actual file path)

Britton C.
Senior Software Engineer
National Instruments
0 Kudos
Message 2 of 2
(3,894 Views)