How to cross compile libvpx for Windows in a Mac OS X


Here I’m again.

I’m working a secret project that needs to link agains libvpx in a Windows environment.

There is almost no information on how to compile libvpx, imagine cross compile in a Mac, well, none.

I successfully compiled it for Windows in a very simple fashion.


  • Xcode
  • MacPorts
  • git
  • mingw32 port installed
  • yasm assembler
  • Git clone of libvpx repository
  • 5 minutes of your time

I’ll not cover how to install XCode neither MacPorts, as it’s straightforward. Xcode can be installed via Mac AppStore, and MacPorts you just need to follow the instructions here. All commands above are intended to be copied and pasted in the Terminal window.

After MacPorts installed, run this command, just in case you already have MacPorts installed(It’ll update your port catalog and upgrade all installed ports):

$ sudo port selfupdate && sudo port upgradeoutdated

Then, we need to install the ports we need:

$ sudo port install i386-mingw32-binutils i386-mingw32-gcc i386-mingw32-runtime i386-mingw32-w32api yasm git-core

This will take some time, just rest and relax.

The next step you must run in a folder that you know, for example, ~/Code/, it’s up to you. Now, let’s clone the libvpx repository:

$ git clone
cd libvpx

This will create a folder called libvpx in the current folder.

In the configure script of libvpx there is a check that is broken in mingw, apply this patch to allow it to run smoothly:

$ patch -p1 << 'EOF'
diff --git a/configure b/configure
index 297cec4..196583a 100755
--- a/configure
+++ b/configure
@@ -555,9 +555,6 @@ process_detect() {
     check_header stdio.h || die "Unable to invoke compiler: ${CC} ${CFLAGS}"
-    check_ld <<EOF || die "Toolchain is unable to link executables"
-int main(void) {return 0;}
     # check system headers
     check_header stdint.h
     check_header pthread.h

It must print a line saying: “patching file configure”.

For the sake of simplicity, I created a script that will configure the toolchain to mingw, here it is:

$ cat > << 'EOF'
export CC=i386-mingw32-gcc
export CXX=i386-mingw32-g++
export CPP=i386-mingw32-cpp
export AR=i386-mingw32-ar
export RANLIB=i386-mingw32-ranlib
export ADD2LINE=i386-mingw32-addr2line
export AS=yasm
export LD=i386-mingw32-ld
export NM=i386-mingw32-nm
export STRIP=i386-mingw32-strip
exec "$@"

Make this script executable:

$ chmod +x

Well, all setup! Let’s configure:

$ ./ ./configure --disable-examples --disable-ssse3 --disable-multithread --enable-vp8 --target=x86-win32-gcc

You must see something like this:

Configuring selected codecs
  enabling vp8_encoder
  enabling vp8_decoder
  enabling vp9_encoder
  enabling vp9_decoder
Configuring for target 'x86-win32-gcc'
  enabling x86
  enabling runtime_cpu_detect
  enabling mmx
  enabling sse
  enabling sse2
  enabling sse3
  using yasm
  checking here for x86inc "x86" "" 
  enabling use_x86inc
  enabling postproc
  enabling unit_tests
Creating makefiles for x86-win32-gcc libs
Creating makefiles for x86-win32-gcc docs

Then, make the lib:

$ ./ make

Well, you will see some warnings, but if there is no errors, you are done!

Search for a libvpx.a file, use it to link against your application!

See ya!

Ps.: I couldn’t build it using multithreading. My project doesn’t need it, but I’m working on it…

– Update October, 25 2013 –

Added missing chmod in


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.