Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. unresolved external symbol
Forum Updated to NodeBB v4.3 + New Features

unresolved external symbol

Scheduled Pinned Locked Moved Unsolved C++ Gurus
9 Posts 3 Posters 6.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • RIVOPICOR Offline
    RIVOPICOR Offline
    RIVOPICO
    wrote on last edited by kshegunov
    #1

    Hi i need help with these type of errors:
    tecladoyraton.obj:-1: error: LNK2019: unresolved external symbol __imp__GetAsyncKeyState@4 referenced in function "short __cdecl comprobarTeclas(void)" (?comprobarTeclas@@YAFXZ)

    Code:

    #include "../headers/tecladoyratonwin.h"
    #include <windows.h>
    
    void enviarTecla(int tecla)
    {
    switch (tecla)
    {
    case Qt::Key_Return:
    tecla = VK_RETURN;
    break;
    case Qt::Key_Backspace:
    tecla = VK_BACK;
    break;
    case Qt::Key_Escape:
    tecla = VK_ESCAPE;
    break;
    case Qt::Key_Shift:
    tecla = VK_SHIFT;
    break;
    case Qt::Key_CapsLock:
    tecla = VK_CAPITAL;
    break;
    }
    keybd_event(tecla, 0, 0, 0);
    keybd_event(tecla, 0, KEYEVENTF_KEYUP, 0);
    }
    
    void hacerClickDerechoP()
    {
    mouse_event( MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0 );
    }
    
    void hacerClickIzquierdoP()
    {
    mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 );
    }
    void hacerClickDerechoS()
    {
    mouse_event( MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0 );
    }
    
    void hacerClickIzquierdoS()
    {
    mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 );
    }
    short comprobarTeclas()
    {
    short i = 0;
    for(i = 0; i < 255; i++){
    if(GetAsyncKeyState(i) == -32767)
    return i;
    }
    return 0;
    }
    

    Code of header:

    #ifndef TECLADOYRATONWIN_H
    #define TECLADOYRATONWIN_H
    #include <Qt>
    
    void enviarTecla(int tecla);
    void hacerClickDerechoP();
    void hacerClickIzquierdoP();
    void hacerClickDerechoS();
    void hacerClickIzquierdoS();
    short comprobarTeclas();
    

    [Moved to C++ Gurus ~kshegunov]

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You are not linking to the user32 library.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • RIVOPICOR Offline
        RIVOPICOR Offline
        RIVOPICO
        wrote on last edited by RIVOPICO
        #3

        hi i included this library with this way: LIBS += -luser32 but still i get other error very similar MSVCRT.lib(crtexe.obj):-1: error: LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup How i could include this library. Thanks in advance. The user library was solved. Only need this MSVCRT.lib

        kshegunovK 1 Reply Last reply
        0
        • RIVOPICOR RIVOPICO

          hi i included this library with this way: LIBS += -luser32 but still i get other error very similar MSVCRT.lib(crtexe.obj):-1: error: LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup How i could include this library. Thanks in advance. The user library was solved. Only need this MSVCRT.lib

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @RIVOPICO said in unresolved external symbol:

          LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup

          You need to have a main() function[1] in your application.

          [1]: http://en.cppreference.com/w/cpp/language/main_function

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            What exactly are you trying to develop ?

            Qt already provides keyboard and mouse handling.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • RIVOPICOR Offline
              RIVOPICOR Offline
              RIVOPICO
              wrote on last edited by p3c0
              #6

              but i included main in this code:

              #include <QApplication>
              #include "mainwindow.h"
              #include <Windows.h>
              #ifndef Q_WS_X11
              #include <QtPlugin>
              #endif
              
              #ifdef _MSC_VER
              int WINAPI WinMain(HINSTANCE hInstance,
                                 HINSTANCE hPrevInstance,
                                 LPSTR lpCmdLine,
                                 int nCmdShow)
              {
                  int argc = 0;
                  char *argv[1];
              #else
              int main(int argc, char *argv[])
              {
              #endif
                  QApplication a(argc, argv);
                  MainWindow w;
                  return a.exec();
              }
              

              Maybe i need to change mi main ??

              kshegunovK 1 Reply Last reply
              0
              • RIVOPICOR RIVOPICO

                but i included main in this code:

                #include <QApplication>
                #include "mainwindow.h"
                #include <Windows.h>
                #ifndef Q_WS_X11
                #include <QtPlugin>
                #endif
                
                #ifdef _MSC_VER
                int WINAPI WinMain(HINSTANCE hInstance,
                                   HINSTANCE hPrevInstance,
                                   LPSTR lpCmdLine,
                                   int nCmdShow)
                {
                    int argc = 0;
                    char *argv[1];
                #else
                int main(int argc, char *argv[])
                {
                #endif
                    QApplication a(argc, argv);
                    MainWindow w;
                    return a.exec();
                }
                

                Maybe i need to change mi main ??

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #7

                @RIVOPICO said in unresolved external symbol:

                Maybe i need to change mi main ??

                No, you need to not use the WinAPI. Here I've given you the most basic of programs and there's no WinMain and there's no #ifdef, because they aren't needed nor at all useful in this case.

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                0
                • RIVOPICOR Offline
                  RIVOPICOR Offline
                  RIVOPICO
                  wrote on last edited by RIVOPICO
                  #8

                  look this:
                  https://msdn.microsoft.com/en-us/library/windows/desktop/ms644990(v=vs.85).aspx
                  i am trying to record my keyboard and mouse

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Please stop posting the same questions several times.

                    This one ends up being exactly the same as this thread.

                    Closing this one.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved