Multiple definition of '__imp___C_specific_handler'
-
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
If I comment this include, the compiler doesn't recognize struct addrinfo as shown below
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.
-
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
If I comment this include, the compiler doesn't recognize struct addrinfo as shown below
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.
-
 or a.libfile (MSVC)? Does that have a runtime.DLLfile which is MSVC or MinGW? Does the.DLLhave 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_32target 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.dllworks.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 socketconnect()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. -
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_32I've replaced it with the following and now the app compiled.
LIBS += -lws2_32 -
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_32I've replaced it with the following and now the app compiled.
LIBS += -lws2_32