My Pages

Sunday, May 29, 2011

How to compile and debug VLC player source code in eclipse IDE on Ubuntu 10.04 (lucid)?


I had been searching for compilation and debugging of the VLC source code in eclipse IDE for a long long time. I could not get much success though. But, finally I got it by myself. And now, I want to share my experience with others, so that guys like me can take the advantage and explore further.


Here is the step by step process of how to compile and debug the source code of VLC media player  in eclipse IDE on Ubuntu 10.04.


Prerequisites:
1. eclipse IDE for C/C++
[can be downloaded from: http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/helios/SR2/eclipse-cpp-helios-SR2-linux-gtk.tar.gz ]


2. source code for VLC media player
[can be downloaded from: http://sourceforge.net/projects/vlc/files/1.1.9/vlc-1.1.9.tar.bz2/download ]


3. Working Internet connection.[probably you may have to download some libraries/packages]


Steps:


Step 1: Download and extraction of code:
    1.1: Download the source code of vlc and save it somewhere [e.g /home/<username>/Downloads]. I am using the latest one [i.e vlc-1.1.9.tar.bz2 ].
    1.2: Extract it. To extract...
-open terminal: Applications-> Accessories-> Terminal
-go to that directory in which source code is kept.
-and run the command: $tar -xvf  vlc-1.1.9.tar.bz2
-this will extract the contents into folder vlc-1.1.9


Step 2: Configure the source code: this step may take several iterations while configuring. Why?, because you may have to resolve some errors while configuring
    2.1: to configure...
-go to the folder vlc-1.1.9
-run the command: $./configure
-if no errors appear, then you are done with configuring the code. Move on to the next step.
-if there are errors, then resolve those error by some means and again run $./configure command.


Error examples: In my case one of the errors was...


To resolve this error, I downloaded and installed libdbus-dev library. For that I did the following...
-open Synaptic Package Manager [System-> Administration-> Synaptic Package Manager]. It will need root/admin password. And enter the library name which needs to be installed.




-right click on the selected library and select 'Mark for Installation'.
-After that click on Apply button[green tick].
-A summary dialog box will open. Click on apply.
-This will download the library and apply the changes[installation].
-After change have been applied. Run the $./configure command. If still errors appear. Do repeat the same process until no errors appear and configuration is successful.
Note: if that doesn't solve the purpose, you may try disabling that library/package by running $./configure –disable-<pack/lib name1> –disable-<pack/lib name2> –disable-<pack/lib name3> ... .




Step 3: Creating and compiling vlc project in eclipse.


    3.1: Download and extract the eclipse file [eclipse-cpp-helios-SR2-linux-gtk.tar.gz] to a folder. Go to eclipse folder and run eclipse executable to run the eclipse IDE.


3.2: Choose a workspace folder.




3.3: Now go to File->New->Project... . A wizard will open.
-Select C/C++ -> C Project, and click Next.


-Enter the project name same as the configured vlc source code folder name [in my case vlc-1.1.9]


-Select project type as Makefile Project-> Empty Project
-Select tool chain as Linux GCC and click on Finish button.



3.4: Importing source code:
-Right click on the project name [vlc-1.1.9] in Project Explorer [left pane] and select Import... . A wizard will open.
-Select General->File System and click on Next button.
 


-Select from directory of configured source code.
-Check the check-box to select all the files inside source folder.
-Click Finish button.


This will import the source code into the project. And start indexing and then after building the source code automatically if Build Automatically option is checked under Project menu of eclipse.


3.5: Building the source code: Once the indexing is done...
-Go to Project-> Build All. And the code will start building...




3.6: Running the vlc after build.
-Right click on the project name [vlc-1.1.9] in Project Explorer [left pane] and select Run As->Run Configurations... . A wizard will open.
-Click on Search Project... button and select vlc as below...
-Click on OK button and then Run button.


This will run the vlc player.
This is it!


And now, as you have vlc-1.1.9 source code configured on your eclipse IDE on Ubuntu 10.04(lucid), you can go through the code, explore it, play with it, and debug it accordingly.




Enjoy!!


Please write your comments, suggestions, inputs as they are always welcome.

13 comments:

  1. Thanks, this was very helpful for a relatively complete newbie with Eclipse and VLC

    -Dan

    ReplyDelete
  2. This is very helpful. Very nice!!

    Rama

    ReplyDelete
  3. Thanks for the nice guide.
    I followed the steps you suggested but I get this error when I try to run build all:

    Description Resource Path Location Type
    fatal error: libavutil/audioconvert.h: No such file or directory vlc line 44 C/C++ Problem

    Do you know what is the reason?
    I checked the libavutil is installed.

    Thanks,

    TJ

    ReplyDelete
  4. thanks nice guide

    ReplyDelete
  5. So far correct but in project properties you have to set c/c++ to
    ../vlc/build

    ReplyDelete
  6. that's good. i hope it suite with my open source software assignment at the university. iaa

    ReplyDelete
  7. thanks alot for that explination

    a question
    where is the main code ( int main() )

    thanks

    ReplyDelete
  8. We followed your procedure but after build all command we got this error

    make[5]: Leaving directory `/home/intecore/workspace/vlc-1.9.9/modules/access/zip'
    make[5]: Entering directory `/home/intecore/workspace/vlc-1.9.9/modules/access'
    CC libaccess_avio_plugin_la-avio.lo
    avio.c:55:5: error: unknown type name 'URLContext'
    URLContext *context;
    ^
    avio.c: In function 'OpenAvio':
    avio.c:95:5: error: implicit declaration of function 'url_open' [-Werror=implicit-function-declaration]
    if (url_open(&sys->context, url, URL_RDONLY) < 0 )
    ^
    avio.c:95:38: error: 'URL_RDONLY' undeclared (first use in this function)
    if (url_open(&sys->context, url, URL_RDONLY) < 0 )
    ^
    avio.c:95:38: note: each undeclared identifier is reported only once for each function it appears in
    avio.c:103:5: error: implicit declaration of function 'url_filesize' [-Werror=implicit-function-declaration]
    const int64_t size = url_filesize(sys->context);
    ^
    In file included from ../../include/vlc_common.h:903:0,
    from avio.c:29:
    avio.c:104:64: error: request for member 'is_streamed' in something not a structure or union
    msg_Dbg(access, "is_streamed=%d size=%"PRIi64, sys->context->is_streamed, size);
    make[5]: Leaving directory `/home/intecore/workspace/vlc-1.9.9/modules/access'
    make[4]: Leaving directory `/home/intecore/workspace/vlc-1.9.9/modules/access'
    make[3]: Leaving directory `/home/intecore/workspace/vlc-1.9.9/modules/access'
    ^
    make[2]: Leaving directory `/home/intecore/workspace/vlc-1.9.9/modules'
    ../../include/vlc_messages.h:105:37: note: in definition of macro 'msg_Dbg'
    make[1]: Leaving directory `/home/intecore/workspace/vlc-1.9.9'
    MODULE_STRING, __VA_ARGS__ )
    ^
    avio.c: In function 'CloseAvio':
    avio.c:130:5: error: implicit declaration of function 'url_close' [-Werror=implicit-function-declaration]
    url_close(sys->context);
    ^
    avio.c: In function 'Read':
    avio.c:143:5: error: implicit declaration of function 'url_read' [-Werror=implicit-function-declaration]
    int r = url_read(access->p_sys->context, data, size);
    ^
    avio.c: In function 'Seek':
    avio.c:157:9: error: implicit declaration of function 'url_seek' [-Werror=implicit-function-declaration]
    url_seek(sys->context, position, SEEK_SET) < 0) {
    ^
    avio.c: In function 'Control':
    avio.c:176:27: error: request for member 'is_streamed' in something not a structure or union
    *b = !sys->context->is_streamed;
    ^
    avio.c:181:26: error: request for member 'prot' in something not a structure or union
    *b = sys->context->prot->url_read_pause != NULL; /* FIXME Unsure */
    ^
    avio.c:195:9: error: implicit declaration of function 'av_url_read_pause' [-Werror=implicit-function-declaration]
    if (av_url_read_pause(sys->context, is_paused)< 0)
    ^
    avio.c: In function 'SetupAvio':
    avio.c:233:5: error: implicit declaration of function 'url_set_interrupt_cb' [-Werror=implicit-function-declaration]
    url_set_interrupt_cb(access ? UrlInterruptCallback : NULL);
    ^
    cc1: some warnings being treated as errors
    make[5]: *** [libaccess_avio_plugin_la-avio.lo] Error 1
    make[4]: *** [all-recursive] Error 1
    make[3]: *** [all] Error 2
    make[2]: *** [all-recursive] Error 1
    make[1]: *** [all-recursive] Error 1
    make: *** [all] Error 2
    plz help to solve this error.

    ReplyDelete
    Replies
    1. I have the same error. Did you solve it? How did you solve? please write the answare, if you found it. many thanks

      Delete
  9. Awsume blog buddy. Thanks for sharing. KMPlayer media player is really today’s most popular video player in the world. It is most comfortable to all format of audio and video. KMPlayer media player

    kmplayer download for windows,

    kmplayer download free

    kmplayer free download latest version

    kmplayer latest media player

    ReplyDelete
  10. Thank you very much. This is really helpful

    ReplyDelete