From 398dc4aaf7f7f084a527a80b32cf9f750c901133 Mon Sep 17 00:00:00 2001 From: Bertrand Lorentz Date: Sun, 23 Feb 2014 17:53:07 +0100 Subject: [PATCH] build: Tell .NET compiler to target the generated assemblies to 32-bit The default value for the "platform" parameter is anycpu, which allows the runtime to use the 64-bit mode on x86_64. This means that any P/Invoke will only work with 64-bit native libraries. The recommended version of native Windows binaries provided by the GTK+ project are 32-bit, so a Gtk# app running on 64-bit Windows will fail to load them, causing a BadImageFormatException at runtime. Using "-platform:x86" instructs the csc compiler to set a flag in the generated assembly that instructs the runtime to use only 32-bit mode. Please note that there are 64-bit GTK+ Windows binaries, but they are marked as experimental, and we probably don't want explore this right now. Also pass the "nologo" parameter so that it doesn't output several useless line when it is invoked. --- configure.ac | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 9fab62e12..ffe6b4697 100644 --- a/configure.ac +++ b/configure.ac @@ -140,6 +140,7 @@ dnl End of has_mono = true else dnl Check for .NET Framework AC_PATH_PROG(CSC, csc.exe, no) +CSFLAGS="-nologo -platform:x86" GACUTIL_FLAGS= GENERATED_SOURCES=generated\\\\*.cs AM_CONDITIONAL(ENABLE_THREADCHECK, false) @@ -174,14 +175,15 @@ PKG_CHECK_MODULES(GIO, gio-2.0 >= $GLIB_REQUIRED_VERSION) AC_SUBST(GIO_CFLAGS) AC_SUBST(GIO_LIBS) -CSFLAGS="$DEBUG_FLAGS $WIN64DEFINES" +CSFLAGS="$CSFLAGS $DEBUG_FLAGS $WIN64DEFINES" +AC_SUBST(CSFLAGS) + PKG_CHECK_MODULES(GLIB_2_31, glib-2.0 >= 2.31, HAVE_GLIB_2_31_OR_HIGHER=yes, HAVE_GLIB_2_31_OR_HIGHER=no) if test "x$HAVE_GLIB_2_31_OR_HIGHER" = "xno" ; then CSFLAGS="$CSFLAGS -define:ENABLE_GTHREAD_INIT" fi -AC_SUBST(CSFLAGS) PKG_CHECK_MODULES(PANGO, pango) AC_SUBST(PANGO_CFLAGS)