-
Notifications
You must be signed in to change notification settings - Fork 19
MSYS2 cross compiling
There are several sections for this document
- Cross Compiler Tool Setup
- Msys2 and Ruby Dependencies
- Ruby
- Shoes
This is tedious. It gets hard when things break and you don't know what to do. Fortunately, the msys2 folks have lots of good info if you know what to do with it. They have patches and configuation instructions. We just have to make them work.
git clone https://github.com/Alexpux/MINGW-packages.git
Inside MINGW-packages are the packages. Let's try bzip2 which is an oddball that they have cleaned up.
cd MINGW-packages/mingw-w64-bzip2
and list the contents. more PKGBUILD
. Open another terminal and cd to where you have the bzip2-1.0.6 created when you did a tar xf bzip2-1.0.6.tar.xz
Now do the patches in the order they do it in the prepare() function.
patch -p1 <../../MINGW-packages/mingw-w64-bzip2/bzip2-1.0.4-bzip2recover.patch
Repeat for the other patches. Because they modified autoconf files (created them in this case) they say to run autoreconf -fi
I use a script to configure for the cross compile based on their script and what I know is needed.
#! /bin/bash
# execute it instead of ./configure
export dest="/home/ccoupe/Projects/shoesdeps/msys2"
export CC=i686-w64-mingw32-gcc
export CPPFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
./configure \
--build=x86_64-linux-gnu \
--host=i686-w64-mingw32 \
--enable-shared \
--prefix=${dest}
Run that in the bzip2-1.0.6 directory and when it finishes, follow their instructions to do make all-dll-shared
.That should compile and link things. Then make install
and check in that --prefix {dest} dir to see if you have the exe's and dll's you expect.
Because we are cross compiling we can't call their prepare and build functions as written. So, it is tedious.
Another one with non-standard instructions. We need to figure out what to do. (we can always start over
patch -p1 <../../MINGW-packages/mingw-w64-zlib/01-zlib-1.2.11-1-buildsys.mingw.patch
patch -p2 <../../MINGW-packages/mingw-w64-zlib/03-dont-put-sodir-into-L.mingw.patch
patch -p1 <../../MINGW-packages/mingw-w64-zlib/04-fix-largefile-support.patch
cd contrib/minizip
git am ../../../../MINGW-packages/mingw-w64-zlib/010-unzip-add-function-unzOpenBuffer.patch
We have a failure! Do git am --abort
. Time to think.... We don't need the contrib/minizip so lets proceed and build w/o it or that patch group. Here's my script:
#! /bin/bash
# execute it instead of ./configure
export dest="/home/ccoupe/Projects/shoesdeps/msys2"
export CC=i686-w64-mingw32-gcc
export CPFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
export INCLUDE_PATH=${dest}/include
export LIBRARY_PATH=${dest}/lib
export BINARY_PATH=${dest}/bin
# for ver 1.2.8:
#make -fwin32/Makefile.gcc
#make install -fwin32/Makefile.gcc SHARED_MODE=1
# for ver 1.2.11:
export CHOST="i686-w64-mingw32"
./configure --prefix=${dest} --shared
make -j1 all
and then do a make install
after that finishes. Check for the Dll and .h file in the correct place.
Just a configure, make, make install. With warnings that exes won't work. True, we can't run exe on this system.
#! /bin/bash
# execute it instead of ./configure
export dest="/home/ccoupe/Projects/shoesdeps/msys2"
export CC=i686-w64-mingw32-gcc
export CPPFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
./configure \
--enable-shared \
--build=x86_64-linux-gnu \
--host=i686-w64-mingw32 \
--prefix="${dest}"
One patch. Pay attention, it's -p2. Details matter.
#! /bin/bash
# execute it instead of ./configure
export dest="/home/ccoupe/Projects/shoesdeps/msys2"
export CC=i686-w64-mingw32-gcc
export CPPFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
./configure \
--build=x86_64-linux-gnu \
--host=i686-w64-mingw32 \
--enable-shared \
--enable-static \
--prefix=${dest}
Although Shoes doesn't use this in Ruby and there are alternatives in Ruby, we'll give it the college try. Ignore the whines about installing exe's.
#! /bin/bash
# execute it instead of ./configure
export dest="/home/ccoupe/Projects/shoesdeps/msys2"
export CC=i686-w64-mingw32-gcc
export CPPFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
./configure \
--build=x86_64-linux-gnu \
--host=i686-w64-mingw32 \
--enable-shared \
--enable-static \
--enable-libgdbm-compat \
--prefix=${dest}
Sigh. Again, I'm going without the wisdom of the msys2 folks and using an older, less tailored openssl-1.0.2k because I know it works with Shoes w/o all the cleverness. You can do something newer is you like. Speaking of clever, openssl has its own build process.
#! /bin/bash
# execute it instead of ./Configure
export dest=/home/ccoupe/Projects/shoesdeps/msys2
export CPPFLAGS="-I${dest}/include"
export LDFLAGS=-L${dest}/lib
./Configure \
--cross-compile-prefix=i686-w64-mingw32- mingw zlib-dynamic shared \
-I${dest}/include \
--prefix="${dest}"
Then make, make install. Both take some time.
NOTE: We have enough dependencies to build Ruby. You can do that now or later.
This happens. A PKGBUILD that want a patch but no patch is given. You'd think that would break the msys2 scripts but evidently not.
Just a configure, make, make install. With warnings that exes won't work. True, we can't run exe on this system. #! /bin/bash
export dest=/home/ccoupe/Projects/shoesdeps/msys2
export CC=i686-w64-mingw32-gcc
export CPPFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
export PKG_CONFIG_PATH=${dest}/lib/pkgconfig
./configure
--build=x86_64-linux-gnu
--host=i686-w64-mingw32
--enable-shared
--prefix=${dest}
I'm not going to use the jpeg-turbo that's used by Msys2. Too me, there too much of chance of getting entangled in non-portable hardware issues plus Shoes doesn't do all that much with Jpeg's. An older one like jpeg-9 will do.
#! /bin/bash
# execute it instead of ./configure
export dest="/home/ccoupe/Projects/shoesdeps/msys2"
export CC=i686-w64-mingw32-gcc
export CPPFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
./configure \
--build=x86_64-linux-gnu \
--host=i686-w64-mingw32 \
--prefix=${dest}
The Msys2 build is more complicated than I like. I'm going with my simpler version. Make a note about that and if further builds claim an xml problem we can come back here for a deeper think.
#! /bin/bash
# execute it instead of ./configure
export dest="/home/ccoupe/Projects/shoesdeps/msys2"
export CC=i686-w64-mingw32-gcc
export CPPFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
./configure \
--build=x86_64-linux-gnu \
--host=i686-w64-mingw32 \
--with-zlib=${dest} \
--without-python \
--prefix=${dest}
Yet again, I'm going with my simple script instead of the msys2 patches and methods. If something else goes wrong, this could be part of the problem.
#! /bin/bash
# execute it instead of ./configure
export dest="/home/ccoupe/Projects/shoesdeps/msys2"
export CC=i686-w64-mingw32-gcc
export CPPFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
./configure \
--build=x86_64-linux-gnu \
--host=i686-w64-mingw32 \
--prefix=${dest}
Expect to spend a lot of time getting this correct and a lot of compile time. W/o patches fails to compile: A 'no' where a command should be when linking? ../woe32dll/c++html-styled-ostream.cc. Hmmn that 120-Fix-Woe32 patch seems like it might help. It also looks like the series of patches involved some removal of code. time for another script to do that - taken form msys2 recipe. And that has some errors in the autogen step. I Do Not Like whats happening.
Menu
In This Section:
- Shoes Rakefiles
- Rake files
- App.yaml secrets
- Custom.yaml
- Gems for Shoes
- Build with Vagrant
- Building Shoes on Linux
- Building Shoes on Pi2
- Mingw Dependencies
- Building Shoes on Windows
- Cross compile mingw
- OSX 10.10 Dependencies
- OSX 10.9 Dependencies
- OSX 10.6 Dependencies
- Caution Using brew 10.6
- Build-MinGW-with-OSX
- NSIS Installer for Windows
- MSYS2 cross compiling
- Cross-compile-for-arm-(raspberry)
- MXE-Dependencies
- FreeBSD and Shoes