Windows – 链接到User32.dll时链接错误2001
我正在尝试链接一个目标文件,该文件使用winuser.h中声明的两个方法并在User32.dll中定义:GetMonitorInfo和WindowFromMonitor.源编译到一个目标文件就好了,但是当我尝试链接时,我得到以下错误输出:
D3dCtx.obj : error LNK2001: unresolved external symbol xGetMonitorInfo D3dCtx.obj : error LNK2001: unresolved external symbol xMonitorFromWindow 问题是,我不称之为“xGetMonitorInfo”或“xMonitorFromWindow”.在所有源文件上运行grep表明只调用了“GetMonitorInfo”和“WindowFromMonitor”.我正确地包括windows.h,其中包括winuser.h.我也正在链接器选项中正确设置我的LIBPATH,这由详细的链接输出确认. 我的详细链接输出中也出现以下内容: Found __imp_GetMonitorInfoA Referenced in nafxcw.lib(afxribboncategory.obj) Referenced in nafxcw.lib(afxtooltipctrl.obj) Referenced in nafxcw.lib(afxribbonkeytip.obj) Referenced in nafxcw.lib(afxfullscreenimpl.obj) Referenced in nafxcw.lib(afxframeimpl.obj) Referenced in nafxcw.lib(afxglobalutils.obj) Referenced in nafxcw.lib(afxdropdowntoolbar.obj) Referenced in nafxcw.lib(wincore.obj) Referenced in nafxcw.lib(afxglobals.obj) Referenced in nafxcw.lib(afxpopupmenu.obj) Referenced in nafxcw.lib(afxpropertygridtooltipctrl.obj) Loaded User32.lib(USER32.dll) Found __imp_MonitorFromWindow Referenced in nafxcw.lib(wincore.obj) Loaded User32.lib(USER32.dll) 此外,GetMonitorInfo在winuser.h中定义为: WINUSERAPI BOOL WINAPI GetMonitorInfoA( __in HMONITOR hMonitor,__inout LPMONITORINFO lpmi); WINUSERAPI BOOL WINAPI GetMonitorInfoW( __in HMONITOR hMonitor,__inout LPMONITORINFO lpmi); #ifdef UNICODE #define GetMonitorInfo GetMonitorInfoW #else #define GetMonitorInfo GetMonitorInfoA #endif // !UNICODE 当我将对“GetMonitorInfo”的所有引用更改为“GetMonitorInfoA”时,我只会得到
作为我的链接器错误输出.不幸的是,MonitorFromWindow似乎没有多个版本可用. 我应该注意到我使用的是64位版本的库,链接和cl. 这里发生了什么,我怎样才能成功链接我的程序? 解决方法
我不知道你是否能够找到解决方案但是我遇到了同样的问题,而且发生这种情况的原因是我有一个名为multimon.h的文件.
看起来在64位编译的情况下,由于宏定义,这些函数的定义来自两个来源,并且可能来自multimon.h的一个是重写并且是错误的. 我只是通过评论这个包括它来解决它,它已经开始链接很好. //#include <multimon.h> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- AD PowerShell for Add Account & OU & Group
- 什么是好的,基于windows和iis(http)的分布式版本控制系统
- powershell Get-WinEvent cmdlt:按时间戳过滤不能产生预期
- .net – 任何人在mscorwks.dll中遇到INT 3调试器中断?
- windows – 如何解决函数GsDriverEntry中引用的LNK2019未解
- 调整Windows扬声器音量VB.NET
- 为Windows 7构建自定义凭据提供程序
- windows-server-2008 – 查找保存端口8443的服务
- windows-runtime – IOutputStream.FlushAsync的返回值是什
- winforms – 删除Windows窗体中的标准图标