Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Multiple definition of '__imp___C_specific_handler'
Qt 6.11 is out! See what's new in the release blog

Multiple definition of '__imp___C_specific_handler'

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 2.4k Views 1 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.
  • P Offline
    P Offline
    pingal
    wrote on last edited by
    #1

    I'm facing some compilation issues as I've migrated my working cpp-project from VS to QT. The app is using low-level windows sockets API's. In one of my header file I've used struct addrinfo which requires

    #include <ws2tcpip.h>
    

    Due to which I'm getting these errors

    Capture.PNG

    If I comment this include, the compiler doesn't recognize struct addrinfo as shown below

    Capture2.PNG

    Here is my .pro file

    QT += quick
    
    CONFIG += c++17
    
    DEFINES += _WIN32_WINNT=0x0602
    LIBS += -LC:/Windows/System32 -lWs2_32
    # You can make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
            ClientResponse.cpp \
            Listen.cpp \
            ServerQueries.cpp \
            base64.cpp \
            client.cpp \
            clientlistwrapper.cpp \
            main.cpp \
    
    RESOURCES += qml.qrc
    
    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH =
    
    # Additional import path used to resolve QML modules just for Qt Quick Designer
    QML_DESIGNER_IMPORT_PATH =
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    HEADERS += \
        ClientResponse.h \
        Listen.h \
        ServerQueries.h \
        base64.h \
        client.h \
        clientlistwrapper.h \
        thread_args.h
    
    FORMS +=
    
    DISTFILES +=
    

    P.S: The same projects builds and run on VS flawlessly.

    JonBJ 1 Reply Last reply
    0
    • P pingal

      I'm facing some compilation issues as I've migrated my working cpp-project from VS to QT. The app is using low-level windows sockets API's. In one of my header file I've used struct addrinfo which requires

      #include <ws2tcpip.h>
      

      Due to which I'm getting these errors

      Capture.PNG

      If I comment this include, the compiler doesn't recognize struct addrinfo as shown below

      Capture2.PNG

      Here is my .pro file

      QT += quick
      
      CONFIG += c++17
      
      DEFINES += _WIN32_WINNT=0x0602
      LIBS += -LC:/Windows/System32 -lWs2_32
      # You can make your code fail to compile if it uses deprecated APIs.
      # In order to do so, uncomment the following line.
      #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
      
      SOURCES += \
              ClientResponse.cpp \
              Listen.cpp \
              ServerQueries.cpp \
              base64.cpp \
              client.cpp \
              clientlistwrapper.cpp \
              main.cpp \
      
      RESOURCES += qml.qrc
      
      # Additional import path used to resolve QML modules in Qt Creator's code model
      QML_IMPORT_PATH =
      
      # Additional import path used to resolve QML modules just for Qt Quick Designer
      QML_DESIGNER_IMPORT_PATH =
      
      # Default rules for deployment.
      qnx: target.path = /tmp/$${TARGET}/bin
      else: unix:!android: target.path = /opt/$${TARGET}/bin
      !isEmpty(target.path): INSTALLS += target
      
      HEADERS += \
          ClientResponse.h \
          Listen.h \
          ServerQueries.h \
          base64.h \
          client.h \
          clientlistwrapper.h \
          thread_args.h
      
      FORMS +=
      
      DISTFILES +=
      

      P.S: The same projects builds and run on VS flawlessly.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @pingal
      This is only a hunch. Your "undefined references" look like symbols from MSVC compiler to me, while you seem to be using MinGW for your compiler/linker?

      1 Reply Last reply
      1
      • P Offline
        P Offline
        pingal
        wrote on last edited by
        #3

        d88d7fc8-6aa0-4c29-828b-23d8d3724aa4-image.png ![a0fc3fc0-7aa0-4f3c-bd37-2a0b773ef31e-image.png](https://ddgobkiprc33d.cloudfront.net

        I'm using MinGW compiler in QT

        JonBJ 1 Reply Last reply
        0
        • P pingal

          d88d7fc8-6aa0-4c29-828b-23d8d3724aa4-image.png ![a0fc3fc0-7aa0-4f3c-bd37-2a0b773ef31e-image.png](https://ddgobkiprc33d.cloudfront.net

          I'm using MinGW compiler in QT

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @pingal
          I know you are. The question is about your use of -lWs2_32. Does that pull in a .a file (MinGW) or a .lib file (MSVC)? Does that have a runtime .DLL file which is MSVC or MinGW? Does the .DLL have any further unsatisfied dependencies?

          Another possibility: you are using 64-bit MinGW. Are you building for 32- or 64-bit? If 64-bit, does -lWs2_32 target 32-bit? Does e.g. https://stackoverflow.com/questions/35003396/mingw-w64-searches-for-libws2-32-dll-instead-of-ws2-32-dll apply to your case? The accepted solution there claims -LC:\Windows\system32 <your files> ws2_32.dll works.

          If that is not the issue. I would concentrate initially on the first error message, "multiple definition", and only look at the further errors after resolving that. I would write a tiny standalone program with #include <ws2tcpip.h> and a minimal socket connect() or similar and get that linking successfully. If that works you need to go look at the code you have using sockets, it might have e.g. MSVC-only #ifs which change the behaviour with a non-MSVC compiler that you need to address.

          1 Reply Last reply
          1
          • P Offline
            P Offline
            pingal
            wrote on last edited by pingal
            #5

            @JonB

            Thank you. I have created a tiny standalone executable on QT which identified the problem, as i think the below line was pulling .lib file

            LIBS += -LC:/Windows/System32 -lWs2_32
            

            I've replaced it with the following and now the app compiled.

            LIBS += -lws2_32
            
            JonBJ 1 Reply Last reply
            0
            • P pingal

              @JonB

              Thank you. I have created a tiny standalone executable on QT which identified the problem, as i think the below line was pulling .lib file

              LIBS += -LC:/Windows/System32 -lWs2_32
              

              I've replaced it with the following and now the app compiled.

              LIBS += -lws2_32
              
              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @pingal
              That is a funny one! Windows should be case-insensitive, filename-wise. However, it looks like MinGW linker is case-sensitive to some degree.

              1 Reply Last reply
              1

              • Login

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