LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Using SetupAPI.h/dll

I am attempting to install a card driver in my CVI 8.1 project using the vendor's code.  Their code uses the windows SetupAPI dll.  I have put #include <setupapi.h> at the top of the .c file.  When I try to run the program, I get the following link errors:
 4 Project link errors
  Undefined symbol '_SetupDiGetClassDevsA@16' referenced in "DDL_Card_Tester.c".
  Undefined symbol '_SetupDiDestroyDeviceInfoList@4' referenced in "DDL_Card_Tester.c".
  Undefined symbol '_SetupDiGetDeviceInterfaceDetailA@24' referenced in "DDL_Card_Tester.c".
  Undefined symbol '_SetupDiEnumDeviceInterfaces@20' referenced in "DDL_Card_Tester.c".
 
I'm running this on a new XP Pro tower.  All of these functions are defined in setupapi.h.
 
Any idea why I'm getting these link errors?
0 Kudos
Message 1 of 7
(10,090 Views)
Hi hendra,

You need to do more than just add the header file to the project. If you are wanting to statically link against the DLL, you need to include the import library (.lib) that is associated with the SetupAPI DLL in the project. Essentially those errors mean that CVI can't find those functions in any linked module. 

Check out the FAQ: Using Dynamic Link Libraries with LabWIndows/CVI tutorial for more information.

Also, if you don't have a import library, you can generate one from the header file. See the Creating Import Libraries for a DLL in LabWindows/CVI KnowledgeBase.

Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 2 of 7
(10,088 Views)
That does answer the question, since I do not have a setupapi.lib file on my computer. 
 
I tried to generate it from CVI and it fails every time.  Is there anyplace where I can download a copy of setupapi.lib?
0 Kudos
Message 3 of 7
(10,070 Views)
With a little more searching I found it posted somewhere, downloaded it, and the program compiles.
 
thanks for your help...
 
But, why didn't the .lib generator in CVI work on setupapi.h/dll?
0 Kudos
Message 4 of 7
(10,069 Views)
Hi hendra,

What types of errors did you get? You should have been able to create that import library so I am curious about what behavior and errors you saw.

Thanks

Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 5 of 7
(10,057 Views)

Hi hendra,

One of my co-workers actually reminded me that SetupAPI.lib is included with the Window SDK that comes with the LabWindows/CVI Full Development System.  In order to install it, you have to have purchased the Full Development System of CVI and they have to install the full SDK from the installer feature tree (i.e. its not turned on by default). 

The SetupAPI files will be installed into

C:\Program Files\National Instruments\CVI81\sdk\include\SetupAPI.h
C:\Program Files\National Instruments\CVI81\sdk\lib\SetupAPI.Lib

Just thoughts I would update you on that information. Regardless, I would still like to know what errors you might have gotten.

Thanks

Best Regards,



Message Edited by Jonathan N on 11-06-2007 02:44 PM
Jonathan N.
National Instruments
0 Kudos
Message 6 of 7
(10,054 Views)
Jonathan,
 
When I try to generate the .lib file, I get the following error popup:
"Error: Unable to create import library.  Error in header file "c:\...\CVI81\sdk\include\SetupAPI.h" at line 33, column 14: syntax error; found '*' expecting ';'.
 
Lines 31-34 are:
 
#ifndef __LPGUID_DEFINED__
#define __LPGUID_DEFINED__
typedef GUID *LPGUID;
#endif
 
If I comment this out, I get a similar message at line 28, the typedef: 
 
#ifndef _HRESULT_DEFINED
#define _HRESULT_DEFINED
typedef LONG HRESULT;
#endif // _HRESULT_DEFINED
 
Try it on your computer.
 
Turns out I have the full version on my desktop, and base versions in my lab, so some .h files were missing in the lab, and a linkage path on the desktop was wrong.  All is worked out now.  Thanks... Gary
0 Kudos
Message 7 of 7
(10,048 Views)