error LNK2019: unresolved external symbol

Hello all,

I have not programmed in Visual C++ in over a decade. I need to write a program to talk to an HP DC power source. I am using Visual C++ 2010.

I am using certain functions that are defined in visa.h header file. Even though I believe I have linked the necessary libraries I get an error, for example, " 1>tft.obj : error LNK2019: unresolved external symbol _viClose@4 referenced in function _main"

I have 6 functions with such errors. I am pretty sure that visa.h resides in one of the following visa32.lib, visa64.lib or nivisa64.lib and so I linked them as:

#pragma comment(lib, "visa32.lib")
#pragma comment(lib, "visa64.lib")
#pragma comment(lib, "nivisa64.lib")

I still get the unresolved external dependencies error. Do I need to declare this function in main even though they are included in the visa.h header file included in the cpp file?

Not sure what I am doing wrong here, can you guys help me with any ideas?

Thank you

#include <wininet.h>
#pragma comment(lib, "wininet")

int main()
//do your stuff
Dear homi,

That didn't seem to remove the errors. Any other suggestions?

Thank you
I've never linked that way in VS2010. I ussually right click on my project, then go to Properties > Configuration Properties > Linker > Input > Additional Dependencies. You can add all of the libraries you want there.

If that isn't the problem, then perhaps your libraries are not in the right directory (or not one that VS2010 searches by default). Try entering the full path such as:
C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\visa32.lib if you are using the default directory for VS.
Excellent point. Maybe my default directory is not set correctly. The .lib and .h file I am interested in is actually located else where at:

C:\Program Files\IVI Foundation\VISA\Win64\Lib_x64\msc

But the VS 2010 is actually installed at:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\deven

However, in VC++ I did go to Properties>Linker>Input>Additional dependencies and link it the directory:

C:\Program Files\IVI Foundation\VISA\Win64\Lib_x64\msc\ and

similar linked the header file at Properties > Configuration Properties > VC++ Directories > and the Include directory and library directories.

But I am sure the problem is that files are not being linked correctly...

Any ideas?
Topic archived. No new replies allowed.