Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

undefined reference to `_com_util::ConvertBSTRToString(wchar_t*)'



  • the following is the .pro file,what have I miss,I have include <comutil>
    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    greaterThan(QT_MAJOR_VERSION, 4): QT += multimedia

    TARGET = FFMPEGQT
    TEMPLATE = app

    The following define makes your compiler emit warnings if you use

    any feature of Qt which has been marked as deprecated (the exact warnings

    depend on your compiler). Please consult the documentation of the

    deprecated API in order to know how to port your code away from it.

    DEFINES += QT_DEPRECATED_WARNINGS

    You can also make your code fail to compile if you use deprecated APIs.

    In order to do so, uncomment the following line.

    You can also select to disable deprecated APIs only up to a certain version of Qt.

    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

    CONFIG += c++11

    INCLUDEPATH += $$PWD/ffmpeg-20200528-c0f01ea-win64-dev/include \

    LIBS += $$PWD/ffmpeg-20200528-c0f01ea-win64-dev/lib/avcodec.lib
    $$PWD/ffmpeg-20200528-c0f01ea-win64-dev/lib/avdevice.lib
    $$PWD/ffmpeg-20200528-c0f01ea-win64-dev/lib/avfilter.lib
    $$PWD/ffmpeg-20200528-c0f01ea-win64-dev/lib/avformat.lib
    $$PWD/ffmpeg-20200528-c0f01ea-win64-dev/lib/avutil.lib
    $$PWD/ffmpeg-20200528-c0f01ea-win64-dev/lib/postproc.lib
    $$PWD/ffmpeg-20200528-c0f01ea-win64-dev/lib/swresample.lib
    $$PWD/ffmpeg-20200528-c0f01ea-win64-dev/lib/swscale.lib
    LIBS += -lole32
    LIBS += -loleaut32
    LIBS += -lstrmiids

    SOURCES +=
    main.cpp
    mainwindow.cpp
    workthread.cpp

    HEADERS +=
    mainwindow.h
    workthread.h

    FORMS +=
    mainwindow.ui
    UI_DIR=./UI

    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target


  • Lifetime Qt Champion

    Hi
    From here
    https://docs.microsoft.com/en-us/cpp/cpp/convertbstrtostring?view=vs-2019
    seems you also have to link
    comsuppw.lib or comsuppwd.lib



  • Hi, this is actually not a Qt-related error.
    You should learn to read Microsoft API docs, espcially the Requirements part, it tells you the header to include and the lib to link.
    Also, when posting, better to wrap your file content with "code" tag (click </>), that'll make it easier to read.



  • i haved added #pragma comment(lib, "comsuppw.lib") but the problem also exists


  • Lifetime Qt Champion

    @yangyanhui4

    Did you try
    LIBS += -lcomsuppw



  • error: cannot find -lcomsuppw


  • Lifetime Qt Champion

    @yangyanhui4

    Then maybe you dont have it ?
    What windows version and compiler are you using ?



  • WIN8.1 QT5.12 mingw 64-bit



  • Are you using MinGW kit?
    This is a MSVC lib. You need to install MSVC build tools and use MSVC version of Qt.


Log in to reply