Search code examples
qt-creatorlibvlc

libvlc_new (0, NULL); segmentation fault


I have a problem when I use this line :

   vlcInstance = libvlc_new(0, NULL);

vlcInstance is declare in my header:

  libvlc_media_player_t *vlcPlayer;

I am using Qt 5.0.1 and I have this error:

The inferior stopped because it received a signal from the Operating System.

Signal name : SIGSEGV Signal meaning : Segmentation fault

Can anyone help me?


Solution

  • I am using Qt Creator 2.7.2 with QT 5.1.0 on 64-bit Kubuntu 13.04. I'm also using vlc-2.2.0-git.

    I created a new QT project.

    I added this to the new project file (change your vlc paths as needed):

    INCLUDEPATH += /home/linux/vlc/install/include
    LIBS += -L"/home/linux/vlc/install/lib" -lvlc
    

    bare-bones main.cpp (including your code that apparently segfaults):

    #include <QtDebug>
    
    #include "vlc/libvlc.h"
    #include "vlc/libvlc_media.h"
    #include "vlc/libvlc_media_player.h"
    
    int main(int argc, char *argv[]) {
        qDebug() << "Starting...";
    
        libvlc_instance_t* p_instance = libvlc_new(0, NULL);
        qDebug() << "p_instance" << p_instance;
    
        if (p_instance) {
            libvlc_media_player_t *p_media_player = libvlc_media_player_new(p_instance);
            qDebug() << "p_media_player" << p_media_player;
    
            if (p_media_player) {
                libvlc_media_player_release(p_media_player);
            }
    
            libvlc_free(p_instance);
        }
    
        qDebug() << "Exit normally";
    }
    

    This runs just fine for me, no segfault:

    Starting... 
    p_instance 0x19140f0 
    p_media_player 0x19da6d8 
    Exit normally