Linking to user32.lib in QTCreator

2020-04-17 07:02发布

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

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.

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

1条回答
唯我独甜
2楼-- · 2020-04-17 07:59

I solved the problem.

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

查看更多
登录 后发表回答