Linker QT error



  • Even if I added [qt+=multimedia to my qt4.8.6 .pro file, I get these errors:

    mainwindow.o: In function MainWindow::MainWindow(QWidget*)': /home/ubuntuccbbb/build-videoplayerbbb-Qt_for_BBB-Debug/../videoplayerbbb/mainwindow.cpp:20: undefined reference toQMediaServiceProvider::defaultServiceProvider()'
    /home/ubuntuccbbb/build-videoplayerbbb-Qt_for_BBB-Debug/../videoplayerbbb/mainwindow.cpp:20: undefined reference to QMediaPlayer::QMediaPlayer(QObject*, QFlags<QMediaPlayer::Flag>, QMediaServiceProvider*)' /home/ubuntuccbbb/build-videoplayerbbb-Qt_for_BBB-Debug/../videoplayerbbb/mainwindow.cpp:22: undefined reference toQMediaPlaylist::QMediaPlaylist(QObject*)'
    /home/ubuntuccbbb/build-videoplayerbbb-Qt_for_BBB-Debug/../videoplayerbbb/mainwindow.cpp:23: undefined reference to QMediaContent::QMediaContent(QUrl const&)' /home/ubuntuccbbb/build-videoplayerbbb-Qt_for_BBB-Debug/../videoplayerbbb/mainwindow.cpp:23: undefined reference toQMediaPlaylist::addMedia(QMediaContent const&)'
    /home/ubuntuccbbb/build-videoplayerbbb-Qt_for_BBB-Debug/../videoplayerbbb/mainwindow.cpp:23: undefined reference to QMediaContent::~QMediaContent()' /home/ubuntuccbbb/build-videoplayerbbb-Qt_for_BBB-Debug/../videoplayerbbb/mainwindow.cpp:24: undefined reference toQMediaContent::QMediaContent(QUrl const&)'
    /home/ubuntuccbbb/build-videoplayerbbb-Qt_for_BBB-Debug/../videoplayerbbb/mainwindow.cpp:24: undefined reference to QMediaPlaylist::addMedia(QMediaContent const&)' /home/ubuntuccbbb/build-videoplayerbbb-Qt_for_BBB-Debug/../videoplayerbbb/mainwindow.cpp:24: undefined reference toQMediaContent::~QMediaContent()'
    /home/ubuntuccbbb/build-videoplayerbbb-Qt_for_BBB-Debug/../videoplayerbbb/mainwindow.cpp:26: undefined reference to QVideoWidget::QVideoWidget(QWidget*)' /home/ubuntuccbbb/build-videoplayerbbb-Qt_for_BBB-Debug/../videoplayerbbb/mainwindow.cpp:27: undefined reference toQMediaPlayer::setVideoOutput(QVideoWidget*)'
    /home/ubuntuccbbb/build-videoplayerbbb-Qt_for_BBB-Debug/../videoplayerbbb/mainwindow.cpp:30: undefined reference to QMediaPlaylist::setCurrentIndex(int)' /home/ubuntuccbbb/build-videoplayerbbb-Qt_for_BBB-Debug/../videoplayerbbb/mainwindow.cpp:31: undefined reference toQMediaPlayer::play()'
    /home/ubuntuccbbb/build-videoplayerbbb-Qt_for_BBB-Debug/../videoplayerbbb/mainwindow.cpp:23: undefined reference to QMediaContent::~QMediaContent()' /home/ubuntuccbbb/build-videoplayerbbb-Qt_for_BBB-Debug/../videoplayerbbb/mainwindow.cpp:24: undefined reference toQMediaContent::~QMediaContent()'

    What more to try?


  • Lifetime Qt Champion

    Hi,

    That because it's not directly part of Qt 4. You need the Qt Mobility module.



  • @SGaist How to include qt mobility in my .pro file?

    QT += mobility doesn't work


  • Lifetime Qt Champion

    You need to build and install the module first. After that you can use QT += multimedia



  • @SGaist I added it but it still doesn't work.


  • Moderators

    @Zola Did you do this first "You need to build and install the module first" as suggested by SGaist??



  • @jsulm Yes module is installed, and it doesn't work.

    Here are the steps I gone through to make project:

    1)Created new project in Qt Creator.

    1. in my main.cpp file I insterted this code

    #include "mainwindow.h"
    #include <QApplication>
    #include <QMediaPlaylist>
    #include <qmobilityglobal.h>
    #include <QVideoWidget>
    #include <QMediaPlayer>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    QMediaPlayer *player = new QMediaPlayer;
    
    QMediaPlaylist *playlist = new QMediaPlaylist(player);
    playlist->addMedia(QUrl("http://example.com/myclip1.mp4"));
    playlist->addMedia(QUrl("http://example.com/myclip2.mp4"));
    
    QVideoWidget *videoWidget = new QVideoWidget;
    player->setVideoOutput(videoWidget);
    
    videoWidget->show();
    playlist->setCurrentIndex(1);
    player->play();
    
    return a.exec();
    

    }

    and changed my pro file to this:

    #-------------------------------------------------

    Project created by QtCreator 2015-11-26T03:58:31

    #-------------------------------------------------

    QT += core gui multimedia multimediawidgets

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = videoplater
    TEMPLATE = app

    INCLUDEPATH += /usr/include/QtMobility/
    INCLUDEPATH += /usr/include/QtMultimediaKit/

    SOURCES += main.cpp
    mainwindow.cpp

    HEADERS += mainwindow.h

    FORMS += mainwindow.ui

    and it gives me errors I wrote above.


  • Moderators

    Same compiler error messages?


  • Lifetime Qt Champion

    Are you sure you built Qt Mobility with the right version of Qt ?



  • @jsulm Look at post above :) I built it with 4.8.7.


  • Lifetime Qt Champion

    One thing that looks suspicious is that you added the include path to QtMobility. If you needed to do that, you would also have to add the link part i.e. LIBS += -lQtMultiMedia -lQtMultiMediaWidgets.

    But it looks like either Qt Mobility is not correctly installed or not built with the same version of Qt you are currently using.



  • @SGaist How I can install required Qt Mobility version when building my qt 4.8.7? ./configure -mobility? or?


  • Lifetime Qt Champion

    First clone the qt-mobility sources:
    git clone git://code.qt.io/qt-mobility/qt-mobility.git

    Do an out of source build:
    mkdir qt-mobility-build
    cd qt-mobility-build
    /path/to/qt-mobility/configure -qmake-exec /path/to/your/qmake
    make && make install


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.