How to check which library is used HOWTO

Many of kdenlive users have several versions of ffmpeg and even mlt. Some from distribution, some may be self compiled.


Part 1. - Suspicious of wrong library is used? How to check it?

It's important especially when you encounter a bug and want to report it.

1) ldd
ldd is standard command line tool from linker tool family usually available in every distro by default.
Change directory

espinosa@esplaptop:~/build/kdenlive/bin> ldd ../lib/libavformat.so
        linux-gate.so.1 =>  (0xffffe000)
        libavutil.so.49 => ../lib/libavutil.so.49 (0xb7f53000)
        libavcodec.so.51 => ../lib/libavcodec.so.51 (0xb7a5b000)
        libz.so.1 => /lib/libz.so.1 (0xb7a1f000)
        libogg.so.0 => /usr/lib/libogg.so.0 (0xb7a19000)
        ....

another example

espinosa@esplaptop:~/build/kdenlive/bin> ldd ../share/mlt/modules/libmltavformat.so
        linux-gate.so.1 =>  (0xffffe000)
        libavformat.so.51 => ../lib/libavformat.so.51 (0xb7ebb000)
        libavcodec.so.51 => ../lib/libavcodec.so.51 (0xb79c3000)
        libavutil.so.49 => ../lib/libavutil.so.49 (0xb79b8000)
        libmlt.so.0.2.3 => ../lib/libmlt.so.0.2.3 (0xb7997000)
        libswscale.so.0 => ../lib/libswscale.so.0 (0xb796a000)
        ...

Check for libavformat, libavcodec (ffmpeg) ans mlt lib paths. These were OK examples, but right paths could differ depending on your build process, prefix settings, LD_RUN_PATH settings etc.

2) run kdenlive with LD_DEBUG flag

espinosa@esplaptop:~/build/kdenlive/bin> LD_DEBUG=libs ./kdenlive
     24563:	find library=libmlt.so.0.2.3 [0]; searching
     24563:	 search path=/opt/kde3/lib/tls/i686/sse2:....:/home/espinosa/build/kdenlive/lib/sse2:/home/espinosa/build/kdenlive/lib		(RUNPATH from file ./kdenlive)
...
     24563:	  trying file=/home/espinosa/build/kdenlive/lib/i686/libmlt.so.0.2.3
     24563:	  trying file=/home/espinosa/build/kdenlive/lib/sse2/libmlt.so.0.2.3
     24563:	  trying file=/home/espinosa/build/kdenlive/lib/libmlt.so.0.2.3   

Warning, the output is very long and detailed.
This way provide the ultimate answer which, how, why this library location was chosen.
As you can clearly see the right libraries were picked by dynamic linker, i.e. those libraries compiled by me.


Part 2. - Wrong library is used? How to change it?

Again, there is several ways how to achieve this.

1) Classic way - set LD_LIBRARY_PATH
in command line
export LD_LIBRARY_PATH=
:$LD_LIBRARY_PATH

and then run ./kdenlive from the same environment

2) use my script when compiling kdenlive :)
This script should inserts the right path directly into binary code wherever you want to build your kdenlive, even to your home dir.
http://www.kdenlive.org/bbforum/viewtopic.php?f=8&t=68

3) compile to /usr/local. Set --prefix=/usr/local/lib when calling configure. Libs in /local
Warning: high risk of breaking functionality of many existing applications (xine, mplayer, amarok..) since the ffmpeg code from SVN may be unstable.

4) Compile to /usr. Set --prefix=/usr when calling configure. This overwrite system files, distribution versions of mentioned software.
Try to remove first ffmpeg and mlt and kdenlive software packages first if you have such installed.
Warning: Even higher risk of problems then in 3)
Warning: uninstalling packages like ffmpeg could prove to be uneasy process as there is a lot of inner dependencies among other packages (mplayer, xine, amarok, avidemux ..)

..and probably more

you wrote:

2) use my script when compiling kdenlive :)
This script should inserts the right path directly into binary code wherever you want to build your kdenlive, even to your home dir.
http://www.kdenlive.org/bbforum/viewtopic.php?f=8&t=68

What's the current link for that?

I have exactly this problem at the moment, and I suppose that I'd have to add something like '-Wl,rpath,${WHICH PATH HERE?}' to the g++ linker options for mlt++ :/