Failing to link against Qt 6.6.2 Multimedia module using CMake
-
Hi,
I have an application I'm trying to build from Qt Creator using CMake, and I can't seem to get it to link properly against the Multimedia module. I've installed the module via the maintenance tool and can see the libraries present under
C:\Qt\6.6.2\msvc2019_64\lib
, so I know it's definitely on my system, and CMake doesn't seem to complain about it being missing.My project is set up as follows:
# Packages: find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Multimedia) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Multimedia) find_package(Tesseract REQUIRED) # Target: qt_add_executable(${PROJECT_NAME} MANUAL_FINALIZATION ${PROJECT_SOURCES} ) # Linking: target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Multimedia Tesseract::libtesseract )
CMake does seem to pick up the Multimedia libraries that it's supposed to link against, because they are present in the linker invocation:
LINK Pass 1: command "C:\PROGRA~2\MICROS~2\2019\PROFES~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo CMakeFiles\tesseract-example.dir\tesseract-example_autogen\mocs_compilation.cpp.obj CMakeFiles\tesseract-example.dir\src\main.cpp.obj CMakeFiles\tesseract-example.dir\src\mainwindow.cpp.obj CMakeFiles\tesseract-example.dir\src\graphicsview.cpp.obj /out:tesseract-example.exe /implib:tesseract-example.lib /pdb:tesseract-example.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:windows C:\Qt\6.6.2\msvc2019_64\lib\Qt6Widgetsd.lib C:\Qt\6.6.2\msvc2019_64\lib\Qt6Multimediad.lib vcpkg_installed\x64-windows\debug\lib\tesseract53d.lib C:\Qt\6.6.2\msvc2019_64\lib\Qt6Guid.lib d3d11.lib dxgi.lib dxguid.lib d3d12.lib C:\Qt\6.6.2\msvc2019_64\lib\Qt6Networkd.lib C:\Qt\6.6.2\msvc2019_64\lib\Qt6Cored.lib mpr.lib userenv.lib C:\Qt\6.6.2\msvc2019_64\lib\Qt6EntryPointd.lib shell32.lib ws2_32.lib vcpkg_installed\x64-windows\debug\lib\archive.lib vcpkg_installed\x64-windows\debug\lib\libcurl-d.lib vcpkg_installed\x64-windows\debug\lib\leptonica-1.83.1d.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\tesseract-example.dir/intermediate.manifest CMakeFiles\tesseract-example.dir/manifest.res" failed (exit code 1120) with the following output:
However, I still get unresolved external symbols:
mainwindow.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QVideoWidget::QVideoWidget(class QWidget *)" (__imp_??0QVideoWidget@@QEAA@PEAVQWidget@@@Z) referenced in function "public: void __cdecl Ui_MainWindow::setupUi(class QMainWindow *)" (?setupUi@Ui_MainWindow@@QEAAXPEAVQMainWindow@@@Z) mainwindow.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl QVideoWidget::~QVideoWidget(void)" (__imp_??1QVideoWidget@@UEAA@XZ) referenced in function "public: virtual void * __cdecl QVideoWidget::`scalar deleting destructor'(unsigned int)" (??_GQVideoWidget@@UEAAPEAXI@Z) mainwindow.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual bool __cdecl QVideoWidget::event(class QEvent *)" (?event@QVideoWidget@@MEAA_NPEAVQEvent@@@Z) mainwindow.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QVideoWidget::hideEvent(class QHideEvent *)" (?hideEvent@QVideoWidget@@MEAAXPEAVQHideEvent@@@Z) mainwindow.cpp.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl QVideoWidget::metaObject(void)const " (?metaObject@QVideoWidget@@UEBAPEBUQMetaObject@@XZ) mainwindow.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QVideoWidget::moveEvent(class QMoveEvent *)" (?moveEvent@QVideoWidget@@MEAAXPEAVQMoveEvent@@@Z) mainwindow.cpp.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl QVideoWidget::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QVideoWidget@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z) mainwindow.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdecl QVideoWidget::qt_metacast(char const *)" (?qt_metacast@QVideoWidget@@UEAAPEAXPEBD@Z) mainwindow.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QVideoWidget::resizeEvent(class QResizeEvent *)" (?resizeEvent@QVideoWidget@@MEAAXPEAVQResizeEvent@@@Z) mainwindow.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QVideoWidget::showEvent(class QShowEvent *)" (?showEvent@QVideoWidget@@MEAAXPEAVQShowEvent@@@Z) mainwindow.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class QSize __cdecl QVideoWidget::sizeHint(void)const " (?sizeHint@QVideoWidget@@UEBA?AVQSize@@XZ) tesseract-example.exe : fatal error LNK1120: 11 unresolved externals
The application did link and run fine before I attempted to use any Multimedia classes, so it seems to only be an issue with the Multimedia libraries. Is there anything I'm missing here?
In case it's helpful, the CMake configuration command that Qt Creator runs is:
Running C:\Program Files\CMake\bin\cmake.exe -S C:/code/qt-tesseract-cpp-example -B C:/code/build-qt-tesseract-cpp-example-Desktop_Qt_6_6_2_MSVC2019_64bit-Debug "-DCMAKE_GENERATOR:STRING=Ninja" "-DCMAKE_BUILD_TYPE:STRING=Debug" "-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=C:\code\build-qt-tesseract-cpp-example-Desktop_Qt_6_6_2_MSVC2019_64bit-Debug/.qtc/package-manager/auto-setup.cmake" "-DQT_QMAKE_EXECUTABLE:FILEPATH=C:/Qt/6.6.2/msvc2019_64/bin/qmake.exe" "-DCMAKE_PREFIX_PATH:PATH=C:/Qt/6.6.2/msvc2019_64" "-DCMAKE_C_COMPILER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/cl.exe" "-DCMAKE_CXX_COMPILER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/cl.exe" "-DCMAKE_CXX_FLAGS_INIT:STRING=" in C:\code\build-qt-tesseract-cpp-example-Desktop_Qt_6_6_2_MSVC2019_64bit-Debug.
-
Hi,
I have an application I'm trying to build from Qt Creator using CMake, and I can't seem to get it to link properly against the Multimedia module. I've installed the module via the maintenance tool and can see the libraries present under
C:\Qt\6.6.2\msvc2019_64\lib
, so I know it's definitely on my system, and CMake doesn't seem to complain about it being missing.My project is set up as follows:
# Packages: find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Multimedia) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Multimedia) find_package(Tesseract REQUIRED) # Target: qt_add_executable(${PROJECT_NAME} MANUAL_FINALIZATION ${PROJECT_SOURCES} ) # Linking: target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Multimedia Tesseract::libtesseract )
CMake does seem to pick up the Multimedia libraries that it's supposed to link against, because they are present in the linker invocation:
LINK Pass 1: command "C:\PROGRA~2\MICROS~2\2019\PROFES~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo CMakeFiles\tesseract-example.dir\tesseract-example_autogen\mocs_compilation.cpp.obj CMakeFiles\tesseract-example.dir\src\main.cpp.obj CMakeFiles\tesseract-example.dir\src\mainwindow.cpp.obj CMakeFiles\tesseract-example.dir\src\graphicsview.cpp.obj /out:tesseract-example.exe /implib:tesseract-example.lib /pdb:tesseract-example.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:windows C:\Qt\6.6.2\msvc2019_64\lib\Qt6Widgetsd.lib C:\Qt\6.6.2\msvc2019_64\lib\Qt6Multimediad.lib vcpkg_installed\x64-windows\debug\lib\tesseract53d.lib C:\Qt\6.6.2\msvc2019_64\lib\Qt6Guid.lib d3d11.lib dxgi.lib dxguid.lib d3d12.lib C:\Qt\6.6.2\msvc2019_64\lib\Qt6Networkd.lib C:\Qt\6.6.2\msvc2019_64\lib\Qt6Cored.lib mpr.lib userenv.lib C:\Qt\6.6.2\msvc2019_64\lib\Qt6EntryPointd.lib shell32.lib ws2_32.lib vcpkg_installed\x64-windows\debug\lib\archive.lib vcpkg_installed\x64-windows\debug\lib\libcurl-d.lib vcpkg_installed\x64-windows\debug\lib\leptonica-1.83.1d.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\tesseract-example.dir/intermediate.manifest CMakeFiles\tesseract-example.dir/manifest.res" failed (exit code 1120) with the following output:
However, I still get unresolved external symbols:
mainwindow.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QVideoWidget::QVideoWidget(class QWidget *)" (__imp_??0QVideoWidget@@QEAA@PEAVQWidget@@@Z) referenced in function "public: void __cdecl Ui_MainWindow::setupUi(class QMainWindow *)" (?setupUi@Ui_MainWindow@@QEAAXPEAVQMainWindow@@@Z) mainwindow.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl QVideoWidget::~QVideoWidget(void)" (__imp_??1QVideoWidget@@UEAA@XZ) referenced in function "public: virtual void * __cdecl QVideoWidget::`scalar deleting destructor'(unsigned int)" (??_GQVideoWidget@@UEAAPEAXI@Z) mainwindow.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual bool __cdecl QVideoWidget::event(class QEvent *)" (?event@QVideoWidget@@MEAA_NPEAVQEvent@@@Z) mainwindow.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QVideoWidget::hideEvent(class QHideEvent *)" (?hideEvent@QVideoWidget@@MEAAXPEAVQHideEvent@@@Z) mainwindow.cpp.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl QVideoWidget::metaObject(void)const " (?metaObject@QVideoWidget@@UEBAPEBUQMetaObject@@XZ) mainwindow.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QVideoWidget::moveEvent(class QMoveEvent *)" (?moveEvent@QVideoWidget@@MEAAXPEAVQMoveEvent@@@Z) mainwindow.cpp.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl QVideoWidget::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QVideoWidget@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z) mainwindow.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdecl QVideoWidget::qt_metacast(char const *)" (?qt_metacast@QVideoWidget@@UEAAPEAXPEBD@Z) mainwindow.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QVideoWidget::resizeEvent(class QResizeEvent *)" (?resizeEvent@QVideoWidget@@MEAAXPEAVQResizeEvent@@@Z) mainwindow.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QVideoWidget::showEvent(class QShowEvent *)" (?showEvent@QVideoWidget@@MEAAXPEAVQShowEvent@@@Z) mainwindow.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class QSize __cdecl QVideoWidget::sizeHint(void)const " (?sizeHint@QVideoWidget@@UEBA?AVQSize@@XZ) tesseract-example.exe : fatal error LNK1120: 11 unresolved externals
The application did link and run fine before I attempted to use any Multimedia classes, so it seems to only be an issue with the Multimedia libraries. Is there anything I'm missing here?
In case it's helpful, the CMake configuration command that Qt Creator runs is:
Running C:\Program Files\CMake\bin\cmake.exe -S C:/code/qt-tesseract-cpp-example -B C:/code/build-qt-tesseract-cpp-example-Desktop_Qt_6_6_2_MSVC2019_64bit-Debug "-DCMAKE_GENERATOR:STRING=Ninja" "-DCMAKE_BUILD_TYPE:STRING=Debug" "-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=C:\code\build-qt-tesseract-cpp-example-Desktop_Qt_6_6_2_MSVC2019_64bit-Debug/.qtc/package-manager/auto-setup.cmake" "-DQT_QMAKE_EXECUTABLE:FILEPATH=C:/Qt/6.6.2/msvc2019_64/bin/qmake.exe" "-DCMAKE_PREFIX_PATH:PATH=C:/Qt/6.6.2/msvc2019_64" "-DCMAKE_C_COMPILER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/cl.exe" "-DCMAKE_CXX_COMPILER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/cl.exe" "-DCMAKE_CXX_FLAGS_INIT:STRING=" in C:\code\build-qt-tesseract-cpp-example-Desktop_Qt_6_6_2_MSVC2019_64bit-Debug.
@Jonathan-Poncelet QVideoWidget is part of MultimediaWidgets : https://doc.qt.io/qt-6.5/qvideowidget.html
Try to therefore link against
Qt6::MultimediaWidgets
. -
Aha, that clears it up, things seem to compile now. Thank you!
-
S SGaist has marked this topic as solved on