Qt: windows functions are unresolved external symbols

后端 未结 2 1988
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-11 20:38

I\'m trying to compile a simple helloworld-like non-Qt C++ application using te WinAPI in QtCreator. Here\'s the code:

#include 

int main()         


        
相关标签:
2条回答
  • 2020-12-11 21:16

    -L sets the search paths for DLLs, but it doesn't actually link anything. The actual linking is done via -l. Setting the search path for system libraries shouldn't be necessary, but you'll need to link against user32:

    win32:LIBS += -luser32
    
    0 讨论(0)
  • 2020-12-11 21:26

    Additional to Frank's answer (which helped me very much, thanks for that!) I would like to add that this is only required vor MSVC, MinGW doesn't seem to need that line. Which was for me the most confusing part, I first thought I had problems with the msvc toolchain.

    My inclusion now looks like this to reflect this fact:

    msvc: LIBS += -luser32
    
    0 讨论(0)
提交回复
热议问题