2007-02-13

How to compile ffmpeg statically

It took me some time to figure this one out. I've never understood all the details of shared vs. static linking. Just thought I would share my experience. This was to enable AAC encoding in linux, and not having to depend on the shared libraries. You can of course add any necessary libraries that you need.


  1. Build libfaac normally (.tar.gz files are somewhat problematic, (linebreaks?) use CVS instead to get properly formatted files. Centos 4.4 was unable to compile this due to outdated autotools, used Debian testing.)

  2. Build ffmpeg with this:

    ./configure --prefix=/home/x/ffmpeginstall/ --enable-faac --extra-libs=/home/x/ffmpeginstall/lib/libfaac.a --enable-gpl --extra-cflags=-I/home/x/ffmpeginstall/include --disable-ffplay --disable-ffserver --disable-shared --disable-debug --extra-ldflags=-L/home/x/ffmpeginstall/lib



2 comments:

Rodrigo Polo said...

I have succesfuly make a static FFMPEG by using the fallowing flags:

./configure \
--enable-static \
--disable-shared \
--extra-libs=-static \
--extra-cflags=--static

Anonymous said...

for version 0.5 i used the suggestion above:
./configure \
--disable-shared \
--enable-static \
--extra-libs=-static \
--extra-cflags=--static

in addition, to get some libraries to compile statically (e.g., --enable-libdirac, --enable-libopenjpeg, and --enable-libvorbis) i needed to edit the ./configure script and the resultant config.mk.

prior to running ./configure i appended "-lm -lstdc++" to line 556 of that script:
check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs -lm -lstdc++

and the appended the same to the EXTRALIBS line of config.mk before running make.