Answers.Body: <p>Thanks for stib's suggestion. I leave my answer here.</p>
  
  <p>FFmepg build process take higher priority to use dynamic library even if static libraries are ready. Therefore, I first removed some external libraries support from build configuration and make sure all external libraries are only static (remove *.dylib from prefix /usr/local/lib). Then rebuild it with the following command:</p>
  
  <pre><code>./configure --pkg-config-flags="--static" --libdir=/usr/local/lib --extra-version=ntd_20150128 --disable-shared --enable-static --enable-gpl --enable-pthreads --enable-nonfree  --enable-libass --enable-libfdk-aac  --enable-libmp3lame  --enable-libx264 --enable-filters --enable-runtime-cpudetect
  </code></pre>
  
  <p>Remember to define <code>--pkg-config-flags="--static"</code>, asking build process to use static library. Then, we will get a single executable FFmpeg binary!</p>
  
  <p>P.S.: I removed the <strong>libass</strong> support from the configuration, because libass depends on Fontconfig lib which I only have dynamic library available. I'll put the libass support back once I figured out how to make a static library of fontconfig.</p>
  
  <p>Thanks.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-05T08:08:11.580Z
Answers.Text: So "--enable-static" is not necessary?!
Answers.UserDisplayName: Dr.jacky
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-06T04:12:06.343Z
Answers.Text: I think --enable-static is still required
Answers.UserDisplayName: Ellis Shen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-06T07:52:44.043Z
Answers.Text: Omg, you've saved my life, I was working on this issue for almost 2 weeks, crawling the web for a solution. And this is it. Thank you !
Answers.UserDisplayName: Yoann
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T03:39:21.280Z
Answers.LastActivityDate: 2015-01-29T03:39:21.280Z
Answers.UserDisplayName: Ellis Shen
Answers.Body: <p>In my CentOS 5.11 and FFmpeg 3.0, I have to use options</p>
  
  <pre><code>--pkg-config-flags="--static"
  --extra-cflags="-I$HOME/ffmpeg/include -static"
  --extra-ldflags="-L$HOME/ffmpeg/lib -static"
  </code></pre>
  
  <p><strong>--enable-static</strong> tell a complier to create the "static libraries" (libav*.a). We can be combine FFmpeg API in the other standalone (static) application.</p>
  
  <p><strong>--disable-shared</strong> tell a complier not to create the "dynamically linked shared object libraries" (libav*.so). These type of libraries can be load and use FFmpeg API by the other application.</p>
  
  <p>These 2 options doesn't complie FFmpeg as standalone static executable.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-19T07:21:55.107Z
Answers.LastActivityDate: 2016-02-20T08:03:55.610Z
Answers.LastEditDate: 2016-02-20T08:03:55.610Z
Answers.UserDisplayName: Boontawee Home
Body: <p>My target is to build a single static FFmpeg binary with libfdkaac and x264 support for OSX and Linux. First, I tried to build one on OSX, I follow the instruction on FFmpeg web:
  <a href="https://trac.ffmpeg.org/wiki/CompilationGuide/MacOSX" rel="noreferrer">https://trac.ffmpeg.org/wiki/CompilationGuide/MacOSX</a></p>
  
  <p><strong>Here is the configuration settings I applied to build a static binary:</strong></p>
  
  <pre><code>./configure pkg_config='pkg-config --static' --prefix=/usr/local --extra-version=ntd_20150126 --disable-shared --enable-static --enable-gpl --enable-pthreads --enable-nonfree --enable-fontconfig --enable-libfreetype --enable-libass --enable-libfdk-aac  --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-filters --enable-runtime-cpudetect
  </code></pre>
  
  <p>After build process, FFmpeg is around 14Mb, which means that it doesn't include the third party libraries. In fact, it requires to link to dynamic libraries located at <code>/usr/local/lib</code>. If I removed those dynamic libs, the FFmpeg will show an error like:</p>
  
  <pre><code>dyld: Library not loaded: /usr/local/lib/libSDL-1.2.0.dylib
  Referenced from: /usr/local/bin/ffmpeg
  Reason: image not found
  Trace/BPT trap: 5
  </code></pre>
  
  <p>Is it the right way to make all external libraries into single static binary?</p>
  
  <p>I would be really appreciate for your help!</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-28T20:30:05.027Z
Comments.Text: I finally figured it out. The reason that dynamic libraries are still linked is because ffmepg build process take higher priority to use dynamic library. Actually I built both dynamic and static libraries in the prefix folder, and Once I removed all *.dylib files from prefix folder, the build process took static library and built single binary successfully.
Comments.UserDisplayName: Ellis Shen
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-29T00:40:55.917Z
Comments.Text: Consider answering your own question for others who are having the same problem.
Comments.UserDisplayName: stib
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-23T06:21:09.657Z
Comments.Text: Doesn't OS X have the `ldd` command, to show the dynamic library dependencies of a binary?  Or just a `file` command with output that includes whether a binary was statically or dynamically linked?
Comments.UserDisplayName: Peter Cordes
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-23T06:22:59.117Z
Comments.Text: Also, yes `--disable-shared --enable-static` should make a static binary.  I think it does on Linux, or when cross-compiling for windows.  So it sounds like a bug in the ffmpeg build scripts on OS X
Comments.UserDisplayName: Peter Cordes
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-23T22:52:29.463Z
Comments.Text: Oops, was just updating my own FFmpeg (on GNU/Linux), and `--enable-static` doesn't make static binaries.  It makes the `libav*` libraries built by ffmpeg (and used by the binaries) static or not.  It doesn't make ffmpeg use static versions of external libraries.  So what you're seeing is the standard behaviour for ffmpeg.
Comments.UserDisplayName: Peter Cordes
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-23T23:30:11.077Z
Comments.Text: Peter, thanks for your sharing and testing on Linux.
Comments.UserDisplayName: Ellis Shen
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-04T14:46:36.540Z
Comments.Text: I'm voting to close this question as off-topic because it is about compilation, not use.
Comments.UserDisplayName: AJ Henderson
Tags: <ffmpeg>
Title: How to compile FFmpeg with libfdkaac into a single static binary?
UserDisplayName: Ellis Shen
ThreadText: # How to compile FFmpeg with libfdkaac into a single static binary?
  
  (Asked by: username_0 on 2015-01-28)
  
  My target is to build a single static FFmpeg binary with libfdkaac and x264 support for OSX and Linux. First, I tried to build one on OSX, I follow the instruction on FFmpeg web:
  <https://trac.ffmpeg.org/wiki/CompilationGuide/MacOSX>
  
  **Here is the configuration settings I applied to build a static binary:**
  
  ```
  ./configure pkg_config='pkg-config --static' --prefix=/usr/local --extra-version=ntd_20150126 --disable-shared --enable-static --enable-gpl --enable-pthreads --enable-nonfree --enable-fontconfig --enable-libfreetype --enable-libass --enable-libfdk-aac  --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-filters --enable-runtime-cpudetect
  
  ```
  
  After build process, FFmpeg is around 14Mb, which means that it doesn't include the third party libraries. In fact, it requires to link to dynamic libraries located at `/usr/local/lib`. If I removed those dynamic libs, the FFmpeg will show an error like:
  
  ```
  dyld: Library not loaded: /usr/local/lib/libSDL-1.2.0.dylib
  Referenced from: /usr/local/bin/ffmpeg
  Reason: image not found
  Trace/BPT trap: 5
  
  ```
  
  Is it the right way to make all external libraries into single static binary?
  
  I would be really appreciate for your help!
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_0**: I finally figured it out. The reason that dynamic libraries are still linked is because ffmepg build process take higher priority to use dynamic library. Actually I built both dynamic and static libraries in the prefix folder, and Once I removed all *.dylib files from prefix folder, the build process took static library and built single binary successfully.  
  > **username_1**: Consider answering your own question for others who are having the same problem.  
  > **username_2**: Doesn't OS X have the `ldd` command, to show the dynamic library dependencies of a binary?  Or just a `file` command with output that includes whether a binary was statically or dynamically linked?  
  > **username_2**: Also, yes `--disable-shared --enable-static` should make a static binary.  I think it does on Linux, or when cross-compiling for windows.  So it sounds like a bug in the ffmpeg build scripts on OS X  
  > **username_2**: Oops, was just updating my own FFmpeg (on GNU/Linux), and `--enable-static` doesn't make static binaries.  It makes the `libav*` libraries built by ffmpeg (and used by the binaries) static or not.  It doesn't make ffmpeg use static versions of external libraries.  So what you're seeing is the standard behaviour for ffmpeg.  
  > **username_0**: username_2, thanks for your sharing and testing on Linux.  
  > **username_3**: I'm voting to close this question as off-topic because it is about compilation, not use.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_6 on 2016-02-19. Score: 5 | Accepted answer
  
  In my CentOS 5.11 and FFmpeg 3.0, I have to use options
  
  ```
  --pkg-config-flags="--static"
  --extra-cflags="-I$HOME/ffmpeg/include -static"
  --extra-ldflags="-L$HOME/ffmpeg/lib -static"
  
  ```
  
  **--enable-static** tell a complier to create the "static libraries" (libav\*.a). We can be combine FFmpeg API in the other standalone (static) application.
  
  **--disable-shared** tell a complier not to create the "dynamically linked shared object libraries" (libav\*.so). These type of libraries can be load and use FFmpeg API by the other application.
  
  These 2 options doesn't complie FFmpeg as standalone static executable.
  
  
  ---
  
  ### Answer by username_0 on 2015-01-29. Score: 11
  
  Thanks for username_1's suggestion. I leave my answer here.
  
  FFmepg build process take higher priority to use dynamic library even if static libraries are ready. Therefore, I first removed some external libraries support from build configuration and make sure all external libraries are only static (remove \*.dylib from prefix /usr/local/lib). Then rebuild it with the following command:
  
  ```
  ./configure --pkg-config-flags="--static" --libdir=/usr/local/lib --extra-version=ntd_20150128 --disable-shared --enable-static --enable-gpl --enable-pthreads --enable-nonfree  --enable-libass --enable-libfdk-aac  --enable-libmp3lame  --enable-libx264 --enable-filters --enable-runtime-cpudetect
  
  ```
  
  Remember to define `--pkg-config-flags="--static"`, asking build process to use static library. Then, we will get a single executable FFmpeg binary!
  
  P.S.: I removed the **libass** support from the configuration, because libass depends on Fontconfig lib which I only have dynamic library available. I'll put the libass support back once I figured out how to make a static library of fontconfig.
  
  Thanks.
  
  > **Comments:**
  > **username_4**: So "--enable-static" is not necessary?!  
  > **username_0**: I think --enable-static is still required  
  > **username_5**: Omg, you've saved my life, I was working on this issue for almost 2 weeks, crawling the web for a solution. And this is it. Thank you !  
  
  ---
  
  