Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libvlc_new always returns NULL

Tags:

c

libvlc

I try to make the tutorial example of libvlc to work. I installed the vlc SDK via sudo apt install libvlc-dev and link against it with -lvlc. Compiling and linking finishes without errors or warnings, but whenever I try to initialize VLC and get the instance with libvlc_new I get NULL as a result.

int
main(int argc, char *argv[argc])
{
  libvlc_instance_t *instance = libvlc_new(0, NULL);
  if (instance == NULL) {
    fprintf(stderr, "Unable to get VLC instance.\n\t%s\n", libvlc_errmsg());
    return EXIT_FAILURE;
  }

  // ... usage of libvlc_media etc., but the program never reaches that point.
}

Whenever I execute the binary I get the result:

$ ./vlc_test some_test_file.mp3
Unable to get VLC instance.
    (null)

My compile options are:

$ gcc -c main.c -o main.o
$ gcc main.o -o vlc_test -lvlc

What am I missing to make libvlc work?

like image 221
danielspaniol Avatar asked Aug 03 '26 19:08

danielspaniol


1 Answers

This question is fairly old now, but I had to dig very deep to find the answer to my problem and that was that I needed to set the environment variable VLC_PLUGIN_PATH to the plugins folder path of the VLC version I linked against.

So in my case (compiling on a Mac):

VLC_PLUGIN_PATH=/Applications/VLC.app/Contents/MacOS/plugins

I hope this helps someone out there struggling to run even the most basic libvlc example.

like image 170
Javaxtreme Avatar answered Aug 05 '26 09:08

Javaxtreme



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!