NI Home > Community > NI Discussion Forums

Measurement Studio for VC++

Reply
Member
cdl3
Posts: 11
0 Kudos

Visual C Link Error

I am trying to link a an NI-Vision program, but am getting the following link errors such as:

 

error LNK2019: unresolved external symbol __imp__imgClose@8 referenced in function _main

unresolved external symbol __imp__imgSessionStopAcquisition@4 referenced in function _main.

 

I have added the folders that contain the appropriate DLL and LIB files, and even tried copying these files directly to my project folders, but nothing has resolved these errors. I have not found any useful documentation on what the __imp__ prefix and @n suffix means either.

 

I am running VC++ 2010 Express on a win7/74 platform. Any help is much appreciated. Thanks.

 

  Charles

 

Member
Tim_O1
Posts: 102
0 Kudos

Re: Visual C Link Error

Hi Charles,

 

Where do you see these errors? I noticed both of the errors have to do with stopping and closing the image session. Does that mean you have an open and start acquisition that are not giving you errors? It could be a matter of incorrect coding or that actual file paths of the functions are incorrect.

 


Tim O

Applications Engineer
National Instruments
Member
cdl3
Posts: 11
0 Kudos

Re: Visual C Link Error

Tim:

 

     Thanks for the response. The code is exactly the HLGrab.c file taken for the NI examples in HL Grab. I added the include and library folders as explained in the previously-referenced link, changed the Precompiled Header setting to Not Use, and built the program as indicated in the instructions. Below is the output.

 

1>------ Build started: Project: CaptureImage, Configuration: Debug Win32 ------
1>  HLGrab.c
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(72): warning C4133: '=' : incompatible types - from 'CHAR *' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(80): warning C4133: 'function' : incompatible types - from 'CHAR [12]' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(80): warning C4133: 'function' : incompatible types - from 'char [7]' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(85): warning C4133: 'function' : incompatible types - from 'char [7]' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(85): warning C4133: 'function' : incompatible types - from 'char [15]' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(90): warning C4133: 'function' : incompatible types - from 'char [7]' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(90): warning C4133: 'function' : incompatible types - from 'char [11]' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(95): warning C4133: 'function' : incompatible types - from 'char [5]' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(95): warning C4133: 'function' : incompatible types - from 'char [5]' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(100): warning C4133: 'function' : incompatible types - from 'char [5]' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(100): warning C4133: 'function' : incompatible types - from 'char [2]' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(105): warning C4133: 'function' : incompatible types - from 'char [7]' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(105): warning C4133: 'function' : incompatible types - from 'char [5]' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(110): warning C4133: 'function' : incompatible types - from 'char [7]' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(110): warning C4133: 'function' : incompatible types - from 'char [5]' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(118): warning C4133: 'function' : incompatible types - from 'char [7]' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(118): warning C4133: 'function' : incompatible types - from 'char [5]' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(196): warning C4133: 'function' : incompatible types - from 'char [64]' to 'LPWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(299): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(371) : see declaration of 'sprintf'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(300): warning C4133: 'function' : incompatible types - from 'char [32]' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(369): warning C4133: 'function' : incompatible types - from 'Int8 [256]' to 'LPCWSTR'
1>c:\projects\cobalt\projects\captureimage\captureimage\hlgrab.c(369): warning C4133: 'function' : incompatible types - from 'char [12]' to 'LPCWSTR'
1>HLGrab.obj : error LNK2019: unresolved external symbol __imp__imgGrabSetup@8 referenced in function _OnGrab
1>HLGrab.obj : error LNK2019: unresolved external symbol __imp__imgSetAttribute2 referenced in function _OnGrab
1>HLGrab.obj : error LNK2019: unresolved external symbol __imp__imgGetAttribute@12 referenced in function _OnGrab
1>HLGrab.obj : error LNK2019: unresolved external symbol __imp__imgSessionOpen@8 referenced in function _OnGrab
1>HLGrab.obj : error LNK2019: unresolved external symbol __imp__imgInterfaceOpen@8 referenced in function _OnGrab
1>HLGrab.obj : error LNK2019: unresolved external symbol __imp__imgPlot2@36 referenced in function _ImaqThread
1>HLGrab.obj : error LNK2019: unresolved external symbol __imp__imgGrab@12 referenced in function _ImaqThread
1>HLGrab.obj : error LNK2019: unresolved external symbol __imp__imgClose@8 referenced in function _StopThread
1>HLGrab.obj : error LNK2019: unresolved external symbol __imp__imgSessionStopAcquisition@4 referenced in function _StopThread
1>HLGrab.obj : error LNK2019: unresolved external symbol __imp__imgShowError@8 referenced in function _DisplayIMAQError
1>C:\Projects\Cobalt\Projects\CaptureImage\Debug\CaptureImage.exe : fatal error LNK1120: 10 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

 

I needed to recreate this project since VC++ Express 2010 was not able to convert the VC++ 6.0 project correctly. Per the instructions, I created a new Win32 program and added the C and H files.

 

  Charles

Member
Tim_O1
Posts: 102
0 Kudos

Re: Visual C Link Error

Hi Charles,

 

Visual Studio 2010 Express does not support MFC libraries. You will need to have the full version in order to run the example. Please let me know if you have any questions or concerns about this and I will be happy to help.

 

Please refer to the documents below for more information.

 

Running National Instruments Examples on Visual Studio 2005 Express for Visual C++

http://digital.ni.com/public.nsf/allkb/22EBFD1B7A5539A4862573D400673729?OpenDocument

 

Visual Studio 2010 Express(“Visual Studio 2010 Express missing quite a bit of features such as MFC”)

http://www.mydigitallife.info/visual-studio-2010-express-free-download/

 

Tim O

Applications Engineer
National Instruments
Member
mozzis
Posts: 4
0 Kudos

Re: Visual C Link Error

This was clearly not a good answer at all. The unresolved external symbols were declared in your header files, they have nothing to do with MFC. You should have advised the user to link with the correct DAQ library.