在<intrin.h>中使用__cpuid()时链接错误?</intrin.h>

时间:2014-04-16 08:21:03

标签: c++ linker-errors cpuid

错误说:

error LNK2019: unresolved external symbol WinCPUID_Init referenced in function 
"public: static void __cdecl CCapturer::GetCPUVendorId(void)" 
 (?GetCPUVendorId@CCapturer@@SAXXZ)

但它没有指出我应该在MSDN _cpuid

中添加哪个库

如何解决?

2 个答案:

答案 0 :(得分:0)

显然它也被fddshow-tryout安装程序使用(我不知道那是什么)并在WinCPUID.dll中定义

external     'WinCPUID_Init@files:WinCPUID.dll cdecl';

我在这里找到了WinCPUID_Init符号的匹配项:

http://code.google.com/p/notepad2-mod/source/browse/branches/inno/distrib/cpu_detection.iss?r=616

代码标题说

// The script is taken from the ffdshow-tryouts installer
// http://sourceforge.net/projects/ffdshow-tryout/

以后

// functions to detect CPU
function WinCPUID_Init(msGetFrequency: Integer; var pInfo: TCPUInfo): Integer;
external     'WinCPUID_Init@files:WinCPUID.dll cdecl';
// function to get system information
procedure GetSystemInfo(var lpSystemInfo: TSystemInfo); external 'GetSystemInfo@kernel32.dll stdcall';


procedure CPUCheck();
var
  CPUInfo: TCPUInfo;
begin
  WinCPUID_Init(0, CPUInfo);

  if (CPUInfo.bIsInitialized = 0) then begin
    // something went wrong
  end
  else begin
    if (CPUInfo.bSSE_Supported  = 1) then begin
      cpu_sse  := true;
    end;
    if (CPUInfo.bSSE2_Supported = 1) then begin
      cpu_sse2 := true;
    end;
  end;
end;

答案 1 :(得分:0)