Using VLC from C code

This is a discussion on Using VLC from C code within the Linux Programming forums, part of the Platform Specific Boards category; << split from dead thread - http://cboard.cprogramming.com/windo...lc-c-code.html >> Hi all This is my first post on this forum so wish ...

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    3

    Using VLC from C code

    << split from dead thread - Using VLC from C code >>

    Hi all

    This is my first post on this forum so wish me luck.

    I am quite new to C programming and started my path using great resources such as this web site. I have now managed to start abit of Linux GUI (GTK+) programming with C.

    I have been looking everywhere for help on this same topic but for the linux platform.

    On the same URL mentioned by Morris83 http://wiki.videolan.org/LibVLC_Tutorial_086c

    There is an example of how to use VLC in your program on a linux platform, but i am finding it very difficult to understand and reproduce.

    Could some one please guide me on how to compile this code on a linux OS.

    I will really appriciate any help no matter how little.

    Kind regards

    Jin
    Last edited by Salem; 03-22-2010 at 11:39 AM. Reason: split

  2. #2
    Registered User
    Join Date
    Mar 2010
    Posts
    3
    Hi

    Could some one please help me compile the following example code, as i am getting errors.

    Compiling Error:

    [root@localhost]$ gcc -g -o test `pkg-config --cflags --libs libvlc` -I/usr/include/vlc/ -lvlc test.c

    test.c: In function ‚main‚:
    test.c:19: warning: passing argument 2 of ‚libvlc_new‚ from incompatible pointer type
    /tmp/ccQbFjCj.o: In function `main':
    /home/jins/code/vlctest/test.c:26: undefined reference to `libvlc_destroy'
    collect2: ld returned 1 exit status


    Example Code from Developer wiki:

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <vlc/libvlc.h>
    
    static void quit_on_exception (libvlc_exception_t *excp) {
    if (libvlc_exception_raised (excp)) {
    fprintf(stderr, "error: %s\n", libvlc_exception_get_message(excp));
    exit(-1);
    }
    }
    
    int main(int argc, char **argv) {
    libvlc_exception_t excp;
    libvlc_instance_t *inst;
    int item;
    char *filename = "/tmp/WorldOfPadman_Intro.avi";
    
    libvlc_exception_init (&excp);
    inst = libvlc_new (argc, argv, &excp);
    quit_on_exception (&excp);
    item = libvlc_playlist_add (inst, filename, NULL, &excp);
    quit_on_exception (&excp);
    libvlc_playlist_play (inst, item, 0, NULL, &excp);
    quit_on_exception (&excp);
    usleep (10000000);
    libvlc_destroy (inst);
    return 0;
    }

    Thanks

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,656
    It's only a dozen lines, and already it's unreadable without indentation.

    > /home/jins/code/vlctest/test.c:26: undefined reference to `libvlc_destroy'
    There is no destroy.
    Quote Originally Posted by man page
    libvlc_instance_t * libvlc_new (int, const char *const *, libvlc_exception_t *)
    Create and initialize a libvlc instance.
    void libvlc_release (libvlc_instance_t *)
    Decrement the reference count of a libvlc instance, and destroy it if it reaches zero.
    VLC: libvlc_core
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Mar 2010
    Posts
    3
    Hi Salem

    Thanks for you reply, could you explain your post a little to me as i am still quite new to C and understanding libvlc.

    Also the compiling errors states a problem with libvlc_new, please see below:

    test.c: In function ‚main‚:
    test.c:19: warning: passing argument 2 of ‚libvlc_new‚ from incompatible pointer type
    /tmp/ccUnr3rr.o: In function `main':
    /home/jins/code/vlctest/test.c:26: undefined reference to `libvlc_destroy'
    collect2: ld returned 1 exit status


    Is the libvlc_new error also related to libvlc_destroy?

    Kind regards

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,656
    The warning you can probably ignore for now (at least long enough to see something work).

    The destroy/release thing however means you're going nowhere until you fix it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  2. Using VLC from C code
    By Morris83 in forum Windows Programming
    Replies: 1
    Last Post: 09-14-2008, 10:33 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 03:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 05:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21