[Mono-dev] Cross Compiling Mono (from Cygwin and more) to Windows - Some Fixes

Matthias Dittrich matthi.d at googlemail.com
Fri Jun 1 15:05:51 UTC 2012


Hello Mono Developers,

I'm working on cross compiling mono in cygwin with the mingw compiler (the
one provided by cygwin not the native one).

I tried something like:
git clone git://github.com/mono/mono.git
cd mono
./build-mingw32.sh
as stated in http://www.mono-project.com/Cross-compiling_Mono_for_Windows

this always failed with something like (i tried some other commands, for
example ./configure --host=.. --build=.. --target=... --prefix=...)
checking for clang "error: cannot run test program while cross compiling"

after some digging I identified the breaking change as the added
mono_cv_clang check, i think i found the solution:
I did the same as somebody did for "linux-android" and set the variables to
prevent the check in my situation.
Note: you have to change mono_cv_clang to yes instead of the no from
android (see diff) or the make will fail.

After i fixed this I got basically this:
http://osdir.com/ml/general/2012-02/msg07752.html
configure: error: /bin/bash ../config.sub dist-bzip2 failed
the link indicates that this will also happen in other cross compile
situations (if not all)

As I found no solution on the mailinglist/web I startet digging again and
found the solution (build-mingw32.sh reads some value from configure.in via
grep and configure.in was changed in the meantime)

This is where I stopped for now... Just want to contribute what I found.
I hope the changes (attached as diff files) are helping somebody out there.

I don't know how and I don't want to checkin directly as I do not have
enough experience with the whole unix build process (started just a few
days ago with cygwin, mono, makefiles, configure and so on...)

Its a little bit sad that the mono project has some pretty decent
documentation on building and embedding, but it fails in practice, hope
this patches help there!

(For me Mono is not compiling as i would expect)
Note: I testet these fixes with the 2.11.1 tar but I'm pretty sure this
will also work on the master branch.

Some thing are left to say:
- There should be some kind on testcase for crosscompiling, to prevent
future breaking changes.
- Where is the best place to add the -static-libgcc and
-static-libstdc++compiler flags?
  So that mono.exe can run without libgcc_s_dw2-1.dll?
- When this all works shouldn't it be better to throw away the current
recommended way of building for windows
 (with the -mno-cygwin flag) in favor of this one
 * the -mno-cygwin flag is obsolete
 * the recommended way of compiling for mingw in cygwin is now the usual
cross compiling
 * the normal cygwin build would then depend on cygwin1.dll (as it is
expected)
 * the mingwbuild is the cross-compile build from above
 * We could use the newest compiler version (gcc4 indead of gcc3) for linux
and windows (so basically drop support if needed).
   I think it should actually be possible to build the current gcc 4.7 for
cygwin with mingw target and then build mono with this (not tested).

Hope this is the right place to post this kind of message.

have a nice weekend,
Matthias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20120601/df3f0691/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: build-mingw32.diff
Type: application/octet-stream
Size: 1000 bytes
Desc: not available
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20120601/df3f0691/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: configure.in.diff
Type: application/octet-stream
Size: 1079 bytes
Desc: not available
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20120601/df3f0691/attachment-0001.obj>


More information about the Mono-devel-list mailing list