[Problem][semi-solved] with linking libvlc to qt



  • Hi guys, I'm trying to make a simple application that uses libvlc, on windows 8.1 using Qt 5.2.1 (MSVC 2010, 32 bit) with minGW.
    my code is:
    @#include <QCoreApplication>
    #include <iostream>
    #include <vlc/vlc.h>

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

    libvlc_instance_t * inst = libvlc_new(argc, argv);
    
    return a.exec&#40;&#41;;
    

    }
    @

    As you see, nothing fancy.
    .pro file:
    @
    #-------------------------------------------------

    Project created by QtCreator 2014-04-29T00:40:02

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

    QT += core

    QT -= gui

    TARGET = libvlcTest
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app

    SOURCES += main.cpp

    unix|win32: LIBS += -L$$PWD/../../../Programs/VideoLAN/VLC/sdk/lib/ -llibvlccore

    INCLUDEPATH += $$PWD/../../../Programs/VideoLAN/VLC/sdk/include
    DEPENDPATH += $$PWD/../../../Programs/VideoLAN/VLC/sdk/include

    unix|win32: LIBS += -L$$PWD/../../../Programs/VideoLAN/VLC/sdk/lib/ -llibvlc

    INCLUDEPATH += $$PWD/../../../Programs/VideoLAN/VLC/sdk/include
    DEPENDPATH += $$PWD/../../../Programs/VideoLAN/VLC/sdk/include
    @

    It builds fine, but when i try to run it, i get two message boxes with errors- one saying "the gdb process terminated unexpectedly(code 0)" and the other one "During startup program exited with code 0xc0000135".
    I have no idea what to do- googled for a lot of time today, and nothing helps. So, does anyone have any idea what might help me?
    Btw, information provided on what one should do to link libvlc to his project are very unclear, i just clicked "add library" in the .pro file and used the path to the libvlc.lib and libvlccore.lib (and paths to their headers).


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Do you have the path to the VLC dlls in your PATH environment variable ? If not, go to the run tab in the Project panel and add it there



  • I pasted the path to the PATH in the run tab, and even tried with the system PATH, but it changes nothing- program stops as soon as it starts and gives me the mentioned errors.
    When i try this:
    @#include <QCoreApplication>
    #include <iostream>
    #include <vlc/vlc.h>

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);
    std::cout<<"szatan";
    libvlc_instance_t * inst = libvlc_new(argc, argv);
    std::cout<<"szatan";
    return a.exec();
    }@
    it displays nothing.
    thanks for your help, do you, or anyone else have any suggestions?


  • Lifetime Qt Champion

    Just saw something strange, are you really using Qt for MSVC 2010 and trying to compile stuff with MinGW ?



  • hmm, that is weird, though everything else compiles nicely:P
    It only says "Qt 5.2.1 (MSVC 2010, 32 bit)" in the Help->About Qt creator window, in my Project tab the qt version is QT 5.2.1 MinGw 32 bit. So i guess thats not the problem here...


  • Lifetime Qt Champion

    That's the Qt version used to build Qt Creator. It's not relevant in this case. What is important is the Qt Version from your Kit which is currently indeed the MinGW build.

    Do you know what compiler was used to build the VLC sdk ?



  • MinGW, i think (its the native method, at least thats what their wiki says, also its in the pkgconfig files next to the .lib files). i know that libraries should be compiled with the same compiler that im using, I just hope that does'nt have to be the same version of compiler.


  • Lifetime Qt Champion

    IIRC, MinGW 4.6 is not compatible with 4.8



  • Ok, so I have discovered, that libvlc is compatible only with qt4.6 7 and 8. In order to run it with qt5, you need to recompile it. I failed at that on windows, but on ubuntu (and for ubuntu- my cross compile attempt also failed miserably) I managed to compile and run it :)
    links to relevant things in the internet:
    http://ubuntuforums.org/showthread.php?t=2141949
    https://forum.videolan.org/viewtopic.php?f=32&t=119194
    https://forum.videolan.org/viewtopic.php?f=32&t=119141

    But now i have a Qt (even without using libvlc) problem- i have downloaded Qt 4.8, installed it, but when i try to build with it, i get GDB error
    "The gdb process terminated unexpectedly (code 0)". I made a new kit in build&run menu, and my settings are:
    Compiler- MinGW 4.8 32 bit (same as in working Qt5.2.1 kit)
    Debugger- extracted from Kit desktop Qt5.2.1 (the working one)
    Qt version 4.8.6
    Is the debugger the source of my problem? Should I download a newer version of gdb?
    I am not sure that the debugger is the source of my problem - if I build and then run program without debug, or just plain remove debugger from kit, the program just doesn't do anything -
    @int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);
    std::cout<<"test";
    int e = 0;
    std::cin>>e;

    return a.exec&#40;&#41;;
    

    }@
    does nothing. (since this is a qt issue, should i post about that elsewhere?)


  • Lifetime Qt Champion

    Just to rule out the obvious, you installed the 4.8.6 MinGW version ?



  • Yep;)


  • Lifetime Qt Champion

    How many versions of Qt do you have installed ? Also which version of Qt Creator do you currently use ?



  • I have Qt Creator 3.1.0, and my qt versions are: 4.8.6 and 5.2.1
    And sorry, i missed one thing- i don't just get one error when trying to debug my program, i get three:
    “The gdb process terminated unexpectedly (code 0)”
    "Cannot continue debugged process:
    The program is not being run." and
    "During startup program exited with code 0xc0000139."
    If I just run it without debug, it exits without doing anything.


  • Lifetime Qt Champion

    That means it can't find one or more dll at startup. Are you sure you have all paths set in your PATH environment variable ?



  • Well, the only difference between the paths from the two kits( 5.2.1 and 4.8.6) are the locations of the qt libraries themselves... should there be any other differences? can these two kits use the same compiler (mingw that came with qt 5.2.1)?


  • Lifetime Qt Champion

    Then you need to add the path to the vlc lib dlls so they can be found at startup



  • Well, I'm having a Qt issue now, because i was talking about simple emtpy program. So I'll say that this topic is answered, and start a new one in approporiate place:) Thanks for your help!


Log in to reply
 

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