libvlc_new (0, NULL); segmentation fault

狂风中的少年 提交于 2019-12-08 02:11:09

问题


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?


回答1:


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



回答2:


Had the same problem on Windows with a simple program linked against prebuilt static lib from the VLC distribution. The solution was just to copy the .dll files and the plugins folder from the VLC distribution root to application folder.



来源:https://stackoverflow.com/questions/17854517/libvlc-new-0-null-segmentation-fault

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!