title: Building FFmpeg for use in Swift
body: <p>With the new XCode/Swift release comes the ability to use binary dependencies. This seems to me to be an ideal time to create an SPM package for FFMpeg.</p>
  <p>However, while I've spent the last year learning to code i Swift, I'm actually not all that familiar with how to build libraries, especially those as complex as FFmpeg with all the configurable libraries and third-party dependencies.</p>
  <p>There's <a href="https://github.com/kewlbear/FFmpeg-iOS-build-script" rel="nofollow noreferrer">kewlbear's iOS build scripts</a>, but these are for iOS/tvOS and ideally an FFMpeg SPM package would be usable for MacOS also. It's also not updated for the newest Xcode and Swift versions.</p>
  <p>My personal interest is simply in audio and I don't need a lot of bells and whistles, but I figure the ideal situation would be a full package with the entire source and whatever dependencies it needs, and then when it's used as a package dependency, the compiler will just use the parts it needs.</p>
  <p>I guess my question is...how would I ideally compile the ffmpeg code for this purpose. I'm trying to <a href="https://trac.ffmpeg.org/wiki/CompilationGuide/macOS#CompilingFFmpegyourself" rel="nofollow noreferrer">follow the directions for compiling yourself</a>, but I'm stuck at the point of compiling <code>gettext</code> because I'm not sure if I should follow the directions (in the <code>gettext</code> source code) for compiling a fat binary for multiple architectures, and when I try to run:</p>
  <pre><code>      ./configure CC=&quot;gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64&quot; \
                    CXX=&quot;g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64&quot; \
                    CPP=&quot;gcc -E&quot; CXXCPP=&quot;g++ -E&quot;
  
  </code></pre>
  <p>I get the following error:</p>
  <pre><code> checking whether the C compiler works... no configure: error: in
   `/Users/nolainecrusher/Downloads/FFMpeg-source/gettext-0.21/gettext-runtime':
   configure: error: C compiler cannot create executables See
   `config.log' for more details configure: error: ./configure failed for
   gettext-runtime
  </code></pre>
  <p>and <code>config.log</code> doesn't really tell me anything useful:</p>
  <p>This is what I see at the end of the log:</p>
  <pre><code> mkdir_p='$(MKDIR_P)' oldincludedir='/usr/include' pdfdir='${docdir}'
   prefix='/usr/local' program_transform_name='s,x,x,' psdir='${docdir}'
   sbindir='${exec_prefix}/sbin' sharedstatedir='${prefix}/com' subdirs='
   gettext-runtime libtextstyle gettext-tools' sysconfdir='${prefix}/etc'
   target_alias=''
  </code></pre>
  <p>I feel like maybe I'm going about this the wrong way, but I'm not sure what the right way is.</p>