2

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

jgpt
  • 129
  • 1
  • 3
  • 11
  • possible duplicate of [Adding external library into Qt Creator project](http://stackoverflow.com/questions/718447/adding-external-library-into-qt-creator-project) – Cody Gray - on strike Jan 17 '12 at 19:39
  • I tried "LIBS += -L$$quote(C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A) -luser32" and read that thread before posting here. – jgpt Jan 17 '12 at 19:57
  • Putting the library in a folder without spaces also does not seem to help: "LIBS += -L C:/qt_applications -luser32" fails – jgpt Jan 17 '12 at 21:49
  • You seriously tried everything suggested in the answers to the other question and *none* of it worked? Did you try it again? Obviously these things worked for other people doing exactly the same thing that you're trying to do. One of the suggestions got at least 40 upvotes. Strange that you can't make it work. – Cody Gray - on strike Jan 18 '12 at 06:13
  • If that's really true, you should update your question with **more specific details** about what exactly you did try, what you mean by "didn't work", what exactly went wrong, etc. Obviously there's something unique about your situation, and if you want a *different* answer, you'll need to make that clear. As it stands, this question is a duplicate. Use the "edit" link underneath the tags. – Cody Gray - on strike Jan 18 '12 at 06:14
  • @CodyGray I added a post because the problem has changed surprisingly. – jgpt Jan 18 '12 at 22:15

1 Answers1

2

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.

jgpt
  • 129
  • 1
  • 3
  • 11
  • Click on the checkbox near the answer to select it as the official answer. I think you'll have to wait another 24hrs or so to do it. – karlphillip Jan 19 '12 at 11:47