Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WMI Linker Error on x64

Tags:

c++

64-bit

wmi

I'm trying to use the WMI example from msdn:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa384724%28v=vs.85%29.aspx

I've copied the last set of code there verbatim into a console application in VS2008. If I have the application in release or debug for the win32 platform, it compiles (and runs) fine. If I have it in release or debug for the x64 platform, I get the following linker errors:

CppConsole.obj : error LNK2001: unresolved external symbol IID_IWbemConfigureRefresher
CppConsole.obj : error LNK2001: unresolved external symbol CLSID_WbemRefresher
CppConsole.obj : error LNK2001: unresolved external symbol IID_IWbemRefresher
CppConsole.obj : error LNK2001: unresolved external symbol CLSID_WbemLocator
CppConsole.obj : error LNK2001: unresolved external symbol IID_IWbemLocator
fatal error LNK1120: 5 unresolved externals

I've already tried putting the wbemuuid.lib into the linker input directly in the project properties, but that didn't make a difference from the pragma.

Has anybody made this work with x64? Or is there something else I'm doing wrong?

like image 245
Kevin Anderson Avatar asked Mar 16 '12 17:03

Kevin Anderson


1 Answers

I give credit to RRUZ for this, as he/she at least put me on the right track, but as they haven't posted an answer-answer (just a comment) I can't click them for credit.

Basically, because of the work environment I'm in, the project directories are set up in a "non-standard" way. There was already a copy of wbemuuid.lib in another directory that was not the correct version (not x64), and that directory was higher on the library include list, thus never getting to the right Windows Platform library directory.

So if you ever have problems with x86 vs x64 and library includes, check your directories and check the ORDER of them as well.

like image 129
Kevin Anderson Avatar answered Oct 11 '22 14:10

Kevin Anderson