使用 GetProcessTimes 和 FileTimeToSystemTime 的 CPU 处理时间在 64 位 win 中不起作用
我正在尝试测量 CPU 时间。 它在 Win 32 上工作得很好,但在 64 位上,它说:
error LNK2019: unresolved external symbol __imp_GetProcessTimes referenced in function "unsigned int __cdecl getWINTime(void)" (?getWIN32Time@@YAIXZ)
它有类似的错误 FileTimeToSystemTime
error LNK2019: unresolved external symbol __imp_FileTimeToSystemTime referenced in function "unsigned int __cdecl getWINTime(void)" (?getWIN32Time@@YAIXZ)
函数本身并不那么重要,没有问题。
这个调用在 64 位架构中合法吗?
这并不是唯一的问题,它似乎没有正确链接到 64 位 Windows 上的库。
我是否应该设置一个设置才能正确链接?
I am trying to measure CPU time.
It works great on Win 32, but on 64 bit, it says:
error LNK2019: unresolved external symbol __imp_GetProcessTimes referenced in function "unsigned int __cdecl getWINTime(void)" (?getWIN32Time@@YAIXZ)
It has similar error for FileTimeToSystemTime
error LNK2019: unresolved external symbol __imp_FileTimeToSystemTime referenced in function "unsigned int __cdecl getWINTime(void)" (?getWIN32Time@@YAIXZ)
Function itself is not that important there is no issue with it.
Are this calls legit in 64 bit architecture or what?
This is not the only issue it seems like its not linking correctly to libraries on 64 bit windows.
Is there a setting I should set for it to link properly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您为两个环境构建的设置是否列出了相同的导入库。这两个函数都位于 kernel32.dll 中。
Do you're build settings for the two environments have the same import libraries listed. Both of those functions are in kernel32.dll.
检查您的链接器标志。 64 位构建的整个项目配置与 32 位构建的不同。因此,请检查您的项目设置以验证它们是否都链接到相同的库。
还可以通过检查项目设置中的命令行窗格或检查构建日志来检查编译器和链接器是否已正确调用。
我刚刚尝试在 Visual Studio 2010 中创建此代码的 64 位版本,并且运行良好:
我只需创建一个新的 Win32 项目,添加一个 64 位平台并进行编译。我根本没有更改任何项目设置。
Check your linker flags. The entire project configuration for 64-bit builds is different from that of 32-bit builds. So check your project settings to verify that they both link to the same libraries.
Also check that the compiler and linker got invoked correctly, either by checking the Command Line panes in project settings, or by inspecting the build log.
I just tried creating a 64-bit build of this code in Visual Studio 2010, and it worked fine:
I simply created a new Win32 project, added a 64-bit platform, and compiled. I didn't change any project settings at all.
GetProcessTimes 和 FileTimeToSystemTime 的文档将告诉您要包含的标头以及要链接到的库文件。但是,Visual Studio 通常会自动为您链接这些内容。
您是否忽略了项目中可能检查的默认库?
The documentation for GetProcessTimes and FileTimeToSystemTime will tell you the headers to include, AND the library file to link to as well. However, Visual studio will usually link those in for you automatically.
Do you have ignore default libraries checked perhaps in your project?