在 QTCreator 中链接到 user32.lib [英] Linking to user32.lib in QTCreator

查看:425
本文介绍了在 QTCreator 中链接到 user32.lib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序需要来自 user32.lib 的 WINAPI 函数 SendInput,并且编译器抱怨对SendInput"的未定义引用.

I need the WINAPI function SendInput from user32.lib for my application and the compiler complains about undefined references to "SendInput".

因此,我尝试通过右键单击项目文件然后使用对话框从 Windows SDK 添加我的文件来链接 user32.lib.QT 创建者在我的 .pro 文件中添加了以下几行:

Thus, I tried to link user32.lib by right-clicking in the project file and then using the dialogue to add my file from the Windows SDK. QT creator has added the following lines to my .pro file:

    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../Program Files 

    (x86)/Microsoft SDKs/Windows/v7.0A/Lib/ -lUser32
     else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../Program Files  
    (x86)/Microsoft SDKs/Windows/v7.0A/Lib/ -lUser32d
    else:symbian: LIBS += -lUser32
     else:unix: LIBS += -L$$PWD/../../../Program Files (x86)/Microsoft SDKs/Windows 
     /v7.0A/Lib/ -lUser32

    INCLUDEPATH += $$PWD/../../../Program Files (x86)/Microsoft SDKs/Windows/v7.0A
    DEPENDPATH += $$PWD/../../../Program Files (x86)/Microsoft SDKs/Windows/v7.0A

不幸的是,虽然所有路径都在那里,但编译器似乎忽略了它.

Unfortunately, although all the paths are there, the compiler seems to ignore it.

我不断收到未定义对 SendInput 的引用"错误.谢谢

I keep getting "Undefined reference to SendInput" errors. Thanks

推荐答案

我解决了这个问题.

我需要在 .pro 文件中定义 WINVER:"DEFINES += "WINVER=0x0500"QT 似乎忽略了头文件中的 #define WINVER 语句.

I needed to define WINVER in the .pro file: "DEFINES += "WINVER=0x0500" QT seems to ignore ofer #define WINVER statements in header files.

这篇关于在 QTCreator 中链接到 user32.lib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆