-4

I saw another post on here with a very similar problem to mine. However, I could not get those suggestions to work. I have installed NI488.2 Version 3.1.2. I am using VC++ 10.0, but I have am using Visual Studio Command Prompt to run c code.

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. I found the visa32.lib and moved in into the lib folder for Visual Studio. It did not work unfortunately. Any other suggestions would be appreciated.

#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;
    }

}

  • You need to tell the linker to link `visa32.lib`. Just dropping it in a folder won't do anything. – nobody May 07 '14 at 20:35
  • Okay, thank you. Do I link this in my .c file? I am really not sure how to link a library. I found this line online as an example but I am not sure what to do with it, $ gcc -o myprog myprog.c -L/home/newhall/lib -lmine – Natalie Cranston May 07 '14 at 20:37

1 Answers1

0

You need to tell the linker to link visa32.lib. In Visual Studio, add it to the list at the following location:

Project -> Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies

If you're compiling on the command line, add /link visa32.lib to your compile command, like so:

cl test.cpp /link visa32.lib
nobody
  • 19,814
  • 17
  • 56
  • 77