Motion - Bug Report 2005x 08x 04x 220823
You are here: Foswiki>Motion Web>BugReports>BugReport2005x08x04x220823 (16 Aug 2005, BruceDurham)Edit Attach

BUG: Motion can't find libavformat.so

With this version, motion can no longer find my ffmpeg shared object libavformat.so

Test case

  1. Ensure that ffmpeg is not installed in the standard directory.
  2. Build ffmpeg with a non-standard installation directory
  3. build motion with option --with-ffmpeg=/dir
  4. Start motion. The following run-time error is displayed:

motion: error while loading shared libraries: libavformat.so: cannot open shared object file: No such file or directory

Attempting the same test-case for motion-3.2.1 produces no error.

Environment

Motion version: 3.2.2_snap9
ffmpeg version: 0.4.9pre1
Shared libraries: curl, xmlrpc, ffmpeg, mysql, postgresql
Server OS: RedHat, kernel 2.4

-- BruceDurham - 04 Aug 2005

Follow up

A couple of questions:

  • What does ldd motion give you? I.e., do libavformat.so and libavcodec.so get resolved (I guess not)?
  • Is the non-standard ffmpeg library folder (i.e., /dir/lib to go with your example) in /etc/ld.so.conf? Does it appear when you run ldconfig -v?

I would guess that putting the library folder in /etc/ld.so.conf and running ldconfig would do the trick. I don't know about RH, but in Gentoo you're not supposed to edit /etc/ld.so.conf directly, but should put files in /etc/env.d instead. Anyway, make sure your newly added library path occurs before any other path that includes an ffmpeg installation (e.g., one in /usr/local/lib).

Generally speaking, Motion does not handle multiple installations of FFMpeg very well, in particular if some are in the ordinary search paths (e.g., /usr/lib or /usr/local/lib) and others are in custom folders. This is, however, a problem with how runtime linking is performed in general and not something that we can blame Motion for. Why it worked for you in a previous version of Motion, I don't know.

A solution to the problem is to edit the makefile and hard-code the paths to libavformat.so and libavcodec.so (off the top of my head, something in line with -l/usr/local/lib/ffmpeg-custom/lib/libavformat.so, but this is neither very elegant nor very flexible. Plus it requires some clumsy additions to the configure script if we want it to happen automatically, if I recall correctly.

-- PerJonsson - 06 Aug 2005


This for sure not a Motion problem.

Exactly where is your ffmpeg source root?

Exactly which configure switches did you run when building ffmpeg?

Did you remember 'make install'?

Exactly which configure switches did you run when building motion?

-- KennethLavrsen - 06 Aug 2005

Fix record

I don't think there is anything to fix.

I tried to uninstall my ffmpeg rpm and install ffmpeg from source newly downloaded from ffmpeg CVS 13 Aug 2005.

I placed the source tree in a directory called /usr/local/ffmpeg-cvs-20050813

And I built it with

./configure --enable-shared
make
make install

I then compiled motion the standard way
./configure
make
make install

Running Motion on my Fedora core 4 gave me this.

motion: error while loading shared libraries: libavformat.so: cannot open shared object file: No such file or directory

So I tried to run ldd motion in /usr/local/bin and the dynamic library loader could not find livavcodec.so and libavframe.so

#ldd motion
...
libavformat.so => not found
libavcodec.so => not found
...

I then looked in /etc/ld.so.conf. On my Fedora Core 4 it has one line: include ld.so.conf.d/*.conf

And looking at the file in /etc/ld.so.conf.d shows that none of them includes /usr/local/lib.

So we have to add this

Either add the line of text /usr/local/lib after the include in /etc/ld.so.conf.

Or create a new file in /etc/ld.so.conf.d that has to have suffix .conf - call it ffmpeg.conf for example and put only one line of text in it - /usr/local/lib.

Now important - run the command ldconfig

And then rebuild Motion with ./configure, make, make install and things should work. This was actually already in the Motion Guide.

-- KennethLavrsen - 13 Aug 2005

Gentlemen,

Thanks for the info. Using your instructions I found out that ldconfig was never in my path (it's in sbin in RH) thus it never ran correctly; My original cache must've been ok with the location of the previous version of ffmpeg.

After correcting this, ldconfig ran correctly and everthing worked ok with ffmpeg-0.4.9 and motion-3.2.2 .

I apologize for the blunder.

-- BruceDurham - 16 Aug 2005
Topic revision: r5 - 16 Aug 2005, BruceDurham
Copyright © 1999-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.