libvlc_new (0, NULL); segmentation fault

血红的双手。 提交于 2019-12-06 08:52:41

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

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.

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