Skip to content

Crosscompiling on Linux

aimmac23 edited this page May 31, 2014 · 2 revisions

Maintaining multiple build platforms sucks - here's how to compile things on a single platform.

Build system: Linux Debian "Jessie"

System setup

Use APT to install mingw compilers - unfortunately I can't remember which ones got installed, so do all of them.

libyuv

Assuming a working installation that was already used to compile the Linux version, run:

CXX=i586-mingw32msvc-gcc make -f linux.mk
i586-mingw32msvc-g++ -o libyuv.dll `ls source/*.o` -Wl,--enable-auto-import -shared

The file should be of an appropriate type for the compiler used:

file libyuv.dll
libyuv.dll: PE32 executable (DLL) (console) Intel 80386, for MS Windows

libvpx

We first need to disable one of the checks in the "configure" script. In the process_detect() function, disable the "if enabled shared" check (in particular where it executes the "die" command.

Next, we run configure:

CROSS=x86_64-w64-mingw32-  ./configure --target=generic-gnu --enable-shared --disable-vp9

The CROSS variable is the prefix of the compiler suite we are using for the cross-compile (probably assumed to be GCC). Setting the "generic-gnu" target enables the use of the CROSS variable.

VP9 is disabled because I encountered issues with the strtok_s being undefined when linking - it was only used in the VP9 codec anyway.

Next, we run make: make

We need to check that the output file is of the correct type (even if it has the wrong extension):

file libvpx.so.1.3.0
libvpx.so.1.3.0: PE32+ executable (DLL) (console) x86-64, for MS Windows

NOTE: I used a 64-bit compiler for the above example.

libmkv

We need to comment out a line in the source - Windows DLLs don't seem to like undefined symbols as much as Linux SO files:

In webmenc.c, comment out the line that calls the "fatal" function - this was expected to be defined elsewhere, but it makes it harder to create libraries. This shouldn't be a problem, as long as the program doesn't run out of memory :)

Similar to the Windows version:

x86_64-w64-mingw32-gcc webmenc.c third_party/libmkv/EbmlWriter.c -I . -shared -o libmkv.dll -lvpx -L .

Clone this wiki locally