Build error using Qt5.2.1 and libvlc-qt



  • I am a total newbie and just learning Qt. I am trying the DemoPlayer example "here":https://github.com/ntadej/vlc-qt that shows how to link Qt to libVLC.

    I installed Qt5.2.1 on a Windows XP machine, vlc-qt-0.8.1 and installed libVLC . I think I have setup the project correctly with the libraries and the include paths but when I build I got errors shown below:

    C:\Qt\vlc-qt-0.8.1\examples\demo-player\src\DemoPlayer.cpp:-1: error: undefined reference to _imp___ZN8VlcMediaC1ERK7QStringbP11VlcInstance' C:\Qt\vlc-qt-0.8.1\examples\demo-player\src\DemoPlayer.cpp:-1: error: undefined reference to_imp___ZN14VlcMediaPlayer4openEP8VlcMedia'
    C:\Qt\vlc-qt-0.8.1\examples\demo-player\src\DemoPlayer.cpp:-1: error: undefined reference to _imp___ZN8VlcMediaC1ERK7QStringP11VlcInstance' C:\Qt\vlc-qt-0.8.1\examples\demo-player\src\DemoPlayer.cpp:-1: error: undefined reference to_imp___ZN14VlcMediaPlayer4openEP8VlcMedia'
    C:\Qt\vlc-qt-0.8.1\examples\demo-player\src\DemoPlayer.cpp:-1: error: undefined reference to _imp___ZN9VlcCommon4argsEv' C:\Qt\vlc-qt-0.8.1\examples\demo-player\src\DemoPlayer.cpp:-1: error: undefined reference to_imp___ZN11VlcInstanceC1ERK11QStringListP7QObject'
    C:\Qt\vlc-qt-0.8.1\examples\demo-player\src\DemoPlayer.cpp:-1: error: undefined reference to _imp___ZN14VlcMediaPlayerC1EP11VlcInstance' C:\Qt\vlc-qt-0.8.1\examples\demo-player\src\DemoPlayer.cpp:-1: error: undefined reference to_imp___ZN14VlcMediaPlayer14setVideoWidgetEP16VlcVideoDelegate'
    C:\Qt\vlc-qt-0.8.1\examples\demo-player\src\DemoPlayer.cpp:-1: error: undefined reference to _imp___ZN14VlcWidgetVideo14setMediaPlayerEP14VlcMediaPlayer' C:\Qt\vlc-qt-0.8.1\examples\demo-player\src\DemoPlayer.cpp:-1: error: undefined reference to_imp___ZN21VlcWidgetVolumeSlider14setMediaPlayerEP14VlcMediaPlayer'
    C:\Qt\vlc-qt-0.8.1\examples\demo-player\src\DemoPlayer.cpp:-1: error: undefined reference to _imp___ZN21VlcWidgetVolumeSlider9setVolumeEi' C:\Qt\vlc-qt-0.8.1\examples\demo-player\src\DemoPlayer.cpp:-1: error: undefined reference to_imp___ZN13VlcWidgetSeek14setMediaPlayerEP14VlcMediaPlayer'
    :-1: error: release/DemoPlayer.o: bad reloc address 0x20 in section `.text$_ZN7QStringD1Ev[__ZN7QStringD1Ev]'
    collect2.exe:-1: error: error: ld returned 1 exit status

    Here are my files:

    demo-player.pro
    @
    TEMPLATE = subdirs

    SUBDIRS +=
    src
    @

    src.pro
    @TARGET = demo-player
    TEMPLATE = app

    QT += core gui widgets

    SOURCES += main.cpp
    DemoPlayer.cpp

    HEADERS += DemoPlayer.h

    FORMS += DemoPlayer.ui

    Edit below for custom library location

    LIBS += -LC:\Qt\libvlc-qt\lib -lvlc-qt -lvlc-qt-widgets
    INCLUDEPATH += C:\Qt\libvlc-qt\include
    @

    DemoPlayer.h

    @TARGET = demo-player
    TEMPLATE = app

    QT += core gui widgets

    SOURCES += main.cpp
    DemoPlayer.cpp

    HEADERS += DemoPlayer.h

    FORMS += DemoPlayer.ui

    Edit below for custom library location

    LIBS += -LC:\Qt\libvlc-qt\lib -lvlc-qt -lvlc-qt-widgets
    INCLUDEPATH += C:\Qt\libvlc-qt\include
    @

    DemoPlayer.cpp
    @
    #include <QFileDialog>
    #include <QInputDialog>

    #include <vlc-qt/Common.h>
    #include <vlc-qt/Instance.h>
    #include <vlc-qt/Media.h>
    #include <vlc-qt/MediaPlayer.h>

    #include "DemoPlayer.h"
    #include "ui_DemoPlayer.h"

    DemoPlayer::DemoPlayer(QWidget *parent)
    : QMainWindow(parent),
    ui(new Ui::DemoPlayer),
    _media(0)
    {
    ui->setupUi(this);

    _instance = new VlcInstance(VlcCommon::args(), this);
    _player = new VlcMediaPlayer(_instance);
    _player->setVideoWidget(ui->video);
    
    ui->video->setMediaPlayer(_player);
    ui->volume->setMediaPlayer(_player);
    ui->volume->setVolume(50);
    ui->seek->setMediaPlayer(_player);
    
    connect(ui->actionOpenLocal, SIGNAL(triggered()), this, SLOT(openLocal()));
    connect(ui->actionOpenUrl, SIGNAL(triggered()), this, SLOT(openUrl()));
    connect(ui->actionPause, SIGNAL(triggered()), _player, SLOT(pause()));
    connect(ui->actionStop, SIGNAL(triggered()), _player, SLOT(stop()));
    connect(ui->openLocal, SIGNAL(clicked()), this, SLOT(openLocal()));
    connect(ui->openUrl, SIGNAL(clicked()), this, SLOT(openUrl()));
    connect(ui->pause, SIGNAL(clicked()), _player, SLOT(pause()));
    connect(ui->stop, SIGNAL(clicked()), _player, SLOT(stop()));
    

    }

    DemoPlayer::~DemoPlayer()
    {
    delete _player;
    delete _media;
    delete _instance;
    delete ui;
    }

    void DemoPlayer::openLocal()
    {
    QString file =
    QFileDialog::getOpenFileName(this, tr("Open file"),
    QDir::homePath(),
    tr("Multimedia files(*)"));

    if (file.isEmpty())
        return;
    
    _media = new VlcMedia(file, true, _instance);
    
    _player->open(_media);
    

    }

    void DemoPlayer::openUrl()
    {
    QString url =
    QInputDialog::getText(this, tr("Open Url"), tr("Enter the URL you want to play"));

    if (url.isEmpty())
        return;
    
    _media = new VlcMedia(url, _instance);
    
    _player->open(_media);
    

    }
    @

    main.cpp

    @#include <QCoreApplication>
    #include <QTextCodec>
    #include <QApplication>

    #include "DemoPlayer.h"

    int main(int argc, char *argv[])
    {
    QCoreApplication::setApplicationName("VLC-Qt Demo Player");
    QCoreApplication::setAttribute(Qt::AA_X11InitThreads);

    //QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    
    QApplication app(argc, argv);
    DemoPlayer mainWindow;
    mainWindow.show();
    
    return app.exec();
    

    }
    @

    I am not sure if this has something to do with the version of Qt that I used? According to "this":http://projects.tano.si/vlc-qt I should be installing Qt 5.1.1 and VLC 2.0.8. I tried installing Qt5.1.1 but did not find the binaries and by the look of it , it seems complicated to rebuild from source.

    Anybody please tell me what I am doing wrong? Any suggestions would be greatly appreciated.



  • I think using Qt 5.1 or 5.2 doesn't matter so much, maybe instead of you have a mixup of compilers?
    What I mean, maybe you are building the Demo Player using the MinGW compiler and libvlc was built with Microsoft's compiler? Or the other way around :-)



  • Thanks for the suggestion.

    I am using vlc-qt-0.8.1 and in the changelog I see

    0.8.1 (2013-04-27)

    • Autodetect Qt4 or Qt5
    • Restored MinGW support
    • Windows SDK updated to Qt 5.0.2 and VLC 2.0.6 with release and debug builds

    The libVLC-qt version that I downloaded is

    libvlc-qt_0.9.0_win32_msvc2012.7z

    so it appears that I downloaded the version compiled with Microsoft compiler.

    When I opened DemoPlayer project in Qt, in the Build Settings I see in the Build steps
    Make: mingw32-make.exe in C:\Qt\vlc-qt-0.8.1\examples\build-demo-player-Desktop_Qt_5_2_1_MinGW_32bit-Release

    Does this mean that this version of DemoPlayer has to be compiled with MinGW or is it because the default compiler that was found was MinGW? I haven't installed Visual Studio in the PC.

    So to make this work, either I install Visual Studio or get version of libvc-qt that will work with MinGW? I looked in this "site":ftp://ftp.videolan.org/pub/videolan/vlc/2.0.7/win32/ but it is not clear which one to choose?



  • Hi, well installing Visual Studio is not easy for you since you're running Windows XP. So the other way, get a libvc-qt that is built with MinGW is your best bet.

    If you cannot find one online, why not try to build it yourself? Download the sources for libvc-qt and give it a try. I don't know if you open libvc-qt as a project in QtCreator or if you compile it with MinGW on the command line, but it should be documented at their site!



  • I'm at the same point.

    I'm going to try to build it using QtCreator, because, if i'm not wrong, i need full version of Visual Studio (not express edition, I mean) and i need to pay for it.

    Did you go further, and can you give me some tips?



  • I was stuck for a while, but just recently I came across this post

    http://qt-project.org/forums/viewthread/37320/

    to configure MinGW to QtCreator

    I will give this one a try.



  • Uh, I'm confused xD

    Wasn't compiled with VS2012? why do you need to configure it to MinGW?

    My QtCreator uses mingw and cannot compile vlc-qt.

    Buf, I must learn more of this... not enough with code... my brain will melt!!


Log in to reply
 

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