在Windows 64中编译32位应用程序时未解析的外部符号

gro*_*rtn 11 c++ winapi win64 visual-studio-2008 kernel32

所以我试图将遗留应用程序从32位编译到64位.我重新编译了它使用的所有库,并使其查看到WIN SDK6.0A x64位用于库.

我在用:

  • Visual Studio Professional Edition 2008
  • Visual C++
  • dotNet Framework 3.5 SP1
  • Windows Server 2008R2
  • Windows SDK是6.0A

Everythings终于出现但我得到这些奇怪的未定义符号错误:

error LNK2019: unresolved external symbol InterlockedDecrement referenced in function ...
error LNK2019: unresolved external symbol InterlockedIncrement referenced in function ...
error LNK2019: unresolved external symbol GetModuleBaseName referenced in ...
error LNK2019: unresolved external symbol EnumProcessModules referenced in ...
error LNK2019: unresolved external symbol EnumProcesses referenced in ...
error LNK2019: unresolved external symbol GetProcessMemoryInfo referenced 
Run Code Online (Sandbox Code Playgroud)

问题是这些都是来自SDK的胜利.InterlockedDec和InterlockedInc来自kernel32.lib GetModuleBaseName,EnumProcessModules,EnumProcesses,GetProcessMemoryInfo在psapi.h中,但也包含kernel32.lib或psapi.lib

I checked C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\x64 and both libs kernel32.lib and psapi.lib are there.

It definitely looks up the libs at right spot. I turned on /VERBOSE:LIB and it points to the correct folder.

So I am really confused why isnt it finding them.

Any ideas???

Thanks

gro*_*rtn 13

所以我终于想通了,有点......它找不到psapi.lib

在项目 - >链接器 - >附加依赖项而不是只是说psapi.lib我给它完整的路径它工作...不确定为什么它以前没有找到它但是哦...

  • 如果你正在使用msvc,你可以使用`#pragma comment(lib,"psapi.lib")`从源代码中添加它. (6认同)