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

发布于 2024-09-07 16:10:28 字数 1224 浏览 12 评论 0原文

所以我正在尝试将遗留应用程序从 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

一切终于即将到来,但我收到这些奇怪的未定义符号错误:

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 

问题是这些都是来自 SDK 的 win 东西。 InterlockedDec 和 InterlockedInc 来自 kernel32.lib GetModuleBaseName、EnumProcessModules、EnumProcesses、GetProcessMemoryInfo 位于 psapi.h 中,但也在 kernel32.lib 或 psapi.lib 中

我检查了 C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\x64 和两个库 kernel32.lib 和 psapi.lib 在那里。

它肯定会在正确的位置查找库。我打开了 /VERBOSE:LIB 它指向正确的文件夹。

所以我真的很困惑为什么它找不到它们。

有什么想法吗???

谢谢

So I am trying to compile legacy app from 32 bit to 64 bit..
I re-compiled all of the libs it used and made it look into WIN SDK6.0A x64 bit for libs..

I am using:

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

Everythings finally coming up but I am getting these weird undefined symbol errors:

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 

The problem is these are all win stuff from SDK.
InterlockedDec and InterlockedInc are coming from kernel32.lib
GetModuleBaseName, EnumProcessModules, EnumProcesses,GetProcessMemoryInfo are in psapi.h but also kernel32.lib or 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

迎风吟唱 2024-09-14 16:10:28

所以我终于明白了,有点...
找到 psapi.lib

它没有在项目 - >链接器 - >其他依赖项中 而不是仅仅说 psapi.lib
我给了它完整的路径并且它有效......
不太清楚为什么之前找不到它,但是哦好吧......

So I finally figured it out, kinda...
It wasnt finding psapi.lib

In Project->Linker->Additional dependencies instead of just saying psapi.lib
I gave full path to it and it worked...
not really sure why it failed to find it before but oh well...

绝影如岚 2024-09-14 16:10:28

这是非常遥远的事情(我真的不相信这就是它),但也许标头没有用 extern "C" 进行适当的保护以进行 c++ 编译?您是包含系统标头还是只是自己声明函数?

This is very long shot (and I don't really believe this is it) but maybe the headers are not properly guarded with extern "C" for c++ compilation? Are you including system headers or just declaring the functions yourself?

满地尘埃落定 2024-09-14 16:10:28

您可以发布您的编译和链接命令行以及代码中的任何 #def 吗?

如果您从头开始创建一个仅调用其中一种方法的简单项目,是否会发生这种情况?

Can you post your compile and link command lines, and any #def's in your code?

Does this happen if you make a simple project from scratch that only calls one of those methods?

淡写薰衣草的香 2024-09-14 16:10:28

郑重声明:同样的问题,不同的解决方案;
一个目录条目,

psapi 

我在列表中添加了

Linker/General/Additional Library Directory 

这导致使用旧的 VS2005 平台 sdk psapi.lib (它只有 x86,没有 x64 版本)。
删除该条目后,现在使用已安装的 WinSDK x64/psapi.lib 中的正确库。
因此,请留意旧的和旧的的混合/订购。新的 SDK!
显然,完整路径也可以工作,但当您在多台计算机上使用该项目时可能会出现问题。

For the record: Same problem, different solution;
I had an entry for the directory

psapi 

added in the list of

Linker/General/Additional Library Directory 

This resulted in the usage of the old VS2005 platform sdk psapi.lib (it only had x86, no x64 version).
After removing the entry the correct lib from the installed WinSDK x64/psapi.lib is used now.
So keep an eye out for mixings/ordering of old & new SDKs!
Obviously the full path will also work but might be a problem when you use the project on multiple machines.

爱情眠于流年 2024-09-14 16:10:28

就我而言(从 VS2008 迁移到 VS2012),在 VS 2012 中的链接器->输入->其他依赖项中添加 psapi.lib 后问题得到解决。

In my case(migrate from VS2008 to VS2012), issue solved after adding psapi.lib in Linker->input->Additional Dependencies in VS 2012.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文