Prerequisites

Preparation

  1. Download everything needed
  2. Extract upx to anywhere you like, extract ucllib as /path/to/upx/ucl, zlibg as /path/to/upx/zlib
  3. Build cross compile docker with docker run --rm dockcross/windows-static-x64 > ./dockcross-win64
  4. Run ./dockcross-win64 bash to enter cross compile environment.

Compile dependencies

UCL

cd ucl
./configure --host=x86_64-w64-mingw32 --enable-static --prefix=/usr/src/mxe/usr/x86_64-w64-mingw32.static/ CPPFLAGS="$CPPFLAGS -std=c90 -fPIC"
make && make install

Zlib

cd zlib
./configure --static --prefix=/usr/src/mxe/usr/x86_64-w64-mingw32.static/
make && make install

Compile UPX

setup env

export UPX_UCLDIR=/work/ucl

Build!

make all

No error should occur and you get your compiled result as src/upx.out!

Congratulations!

And I also prepared a compiled file for your lazy guys upx-4.0.0.zip