Linking problem with Vlc Qt library



  • I have download VLC-Qt library from here . I unzipped and copied all files to my project folder. This is my .pro file :

    
    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = untitled7
    TEMPLATE = app
    SOURCES += main.cpp\
            mainwindow.cpp\
    
    HEADERS  += mainwindow.h\
    
    
    
    FORMS    += mainwindow.ui
    INCLUDEPATH += $$PWD\include
    LIBS += -Llib -lvlc-qt
    
    

    My main.cpp file :

    #include "mainwindow.h"
    #include <QApplication>
    #include <QStringList>
    #include <vlc-qt/Instance.h>
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
      QStringList list{"media.mp3"};
      VlcInstance h(list);
      return a.exec();
    }
    
    

    When I try to run this code it shows following errors:

    main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl VlcInstance::VlcInstance(class QStringList const &,class QObject *)" (__imp_??0VlcInstance@@QEAA@AEBVQStringList@@PEAVQObject@@@Z) referenced in function main
    main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl VlcInstance::~VlcInstance(void)" (__imp_??1VlcInstance@@UEAA@XZ) referenced in function main
    debug\untitled7.exe:-1: error: LNK1120: 2 unresolved externals
    

    I have tried rebuilding the project and ran Qmake but this this error keeps showing up. What am I doing wrong ? How can I fix this ?


  • Moderators

    What am I doing wrong ?

    You're not linking to the vlc library.

    How can I fix this ?

    Link to the library. If it's in <your project dir>\vlc\lib\vlc-qt.lib you can do this by adding this to the .pro file:

    LIBS += -Lvlc\lib -lvlc-qt
    

    Adjust paths accordingly if you have vlc located elsewhere.

    Please note that if you downloaded the precompiled package (e.g. Windows 64-bit MSVC2012 Qt5) you will have to use the same compiler (VS2012) for your project. If you're using different compiler then you need to download the source package and build it yourself with your compiler.



  • @Chris-Kawa Okay so I have updated the .pro file and downloaded https://github.com/vlc-qt/vlc-qt/releases/tag/1.0.1t version which is compatible with msvc2013 but this time I am getting this error :

    :-1: error: LNK1104: cannot open file 'vlc-qt.lib'
    


  • @Chris-Kawa Okay so the linking problem is finally fixed but when the program runs it crashes showing this message:
    "The program has unexpectedly finished."


  • Moderators

    Could be any number of problems.
    Is it compiled with exactly the same compiler version (i.e. MSVC update version)? Is it compiled with the same version of Qt as the one you use? Have you copied the vlc dlls to your app's output dir?



  • @Chris-Kawa How can I fix this issue? Is there any other way to play all video and audio formats using QMediaPlayer without using these VLC libraries ?


  • Lifetime Qt Champion

    Hi,

    Like @chris-kawa suggested, copy the VLC .dlls where the application was built. Or go to the Run part of the Project panel in Qt Creator and modify the PATH environment variable by adding the path to where the VLC .dlls files are located.



  • @SGaist After copying the .dll files, when I open the application, this error message is displayed:
    "the procedure entry point could not be located in dynamuc link library <location>\VLCQtCore.dll"


  • Moderators

    Sounds like what I said earlier - the vlc dll was probably compiled with different Qt version than what you're using in your project. These need to match.


Log in to reply
 

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