This is the mail archive of the gsl-discuss@sourceware.org mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch for compilation for a mingw32 host


Hi,

I have recently been cross compiling GSL shared libraries (DLLs) on a
linux machine for a mingw32msvc host, and needed to use the attached
patch to make this work. I believe this patch would also be
useful/needed if you were simply compiling inside MSYS/mingw32, or
with cygwin and the -mno-cygwin option - I haven't tried either of
these things though. Without this patch it is not possible to build a
shared library for this host. n explanation follows.

The following are specific to mingw32 (i.e. Windows) hosts. Windows
does not allow DLLs with undefined symbols and so we need the
-no-undefined options for GCC. We also need to link against the
gslcblas library to resolve the cblas symbols. This means it is then
probably not possible to drop in a replacement cblas library at
runtime. To use a different cblas library, it is probably necessary to
link it at build time unless the alternative library is ABI
compatible.

Note that in principle, libtool should add the -no-undefined option if
it detects mingw is the host arch, but at this point in time libtool
doesn't (at least for 1.5.22) and the libtool developers recommend
adding it manually. I expect this will get fixed in a later release of
libtool.

These patches have (hopefully) been put together in such a way as they
won't impact building for any other host arch.

Best wishes,
Jonathan.

diff -ru gsl-1.9/cblas/Makefile.am gsl-1.9-mingw/cblas/Makefile.am
--- gsl-1.9/cblas/Makefile.am   2004-09-11 14:45:09.000000000 +0100
+++ gsl-1.9-mingw/cblas/Makefile.am     2007-07-08 00:05:00.000000000 +0100
@@ -1,6 +1,11 @@
lib_LTLIBRARIES = libgslcblas.la
libgslcblas_la_LDFLAGS = -version-info $(GSL_LT_CBLAS_VERSION)

+MINGW32_HOST = @MINGW32_HOST@
+if MINGW32_HOST
+libgslcblas_la_LDFLAGS += -no-undefined
+endif
+
pkginclude_HEADERS = gsl_cblas.h

INCLUDES= -I$(top_srcdir)
diff -ru gsl-1.9/configure.ac gsl-1.9-mingw/configure.ac
--- gsl-1.9/configure.ac        2007-02-20 13:08:16.000000000 +0000
+++ gsl-1.9-mingw/configure.ac  2007-07-08 00:04:38.000000000 +0100
@@ -89,6 +89,14 @@

dnl Checks for typedefs, structures, and compiler characteristics.

+case "$host_os" in
+     *mingw*)
+       MINGW=true
+       ;;
+esac
+
+AM_CONDITIONAL(MINGW32_HOST, test "$MINGW" = "true")
+
dnl Checks for library functions.

dnl AC_FUNC_ALLOCA
diff -ru gsl-1.9/Makefile.am gsl-1.9-mingw/Makefile.am
--- gsl-1.9/Makefile.am 2006-11-02 17:50:01.000000000 +0000
+++ gsl-1.9-mingw/Makefile.am   2007-07-08 00:04:45.000000000 +0100
@@ -21,6 +21,12 @@
libgsl_la_LDFLAGS = -version-info $(GSL_LT_VERSION)
noinst_HEADERS = templates_on.h templates_off.h

+MINGW32_HOST = @MINGW32_HOST@
+if MINGW32_HOST
+libgsl_la_LIBADD += cblas/libgslcblas.la
+libgsl_la_LDFLAGS += -no-undefined
+endif
+
m4datadir = $(datadir)/aclocal
m4data_DATA = gsl.m4
diff -ru gsl-1.9/cblas/Makefile.am gsl-1.9-mingw/cblas/Makefile.am
--- gsl-1.9/cblas/Makefile.am	2004-09-11 14:45:09.000000000 +0100
+++ gsl-1.9-mingw/cblas/Makefile.am	2007-07-08 00:05:00.000000000 +0100
@@ -1,6 +1,11 @@
 lib_LTLIBRARIES = libgslcblas.la
 libgslcblas_la_LDFLAGS = -version-info $(GSL_LT_CBLAS_VERSION)
 
+MINGW32_HOST = @MINGW32_HOST@
+if MINGW32_HOST
+libgslcblas_la_LDFLAGS += -no-undefined
+endif
+
 pkginclude_HEADERS = gsl_cblas.h
 
 INCLUDES= -I$(top_srcdir)
diff -ru gsl-1.9/configure.ac gsl-1.9-mingw/configure.ac
--- gsl-1.9/configure.ac	2007-02-20 13:08:16.000000000 +0000
+++ gsl-1.9-mingw/configure.ac	2007-07-08 00:04:38.000000000 +0100
@@ -89,6 +89,14 @@
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 
+case "$host_os" in
+     *mingw*)
+	MINGW=true
+	;;
+esac
+
+AM_CONDITIONAL(MINGW32_HOST, test "$MINGW" = "true")
+
 dnl Checks for library functions.
 
 dnl AC_FUNC_ALLOCA
diff -ru gsl-1.9/Makefile.am gsl-1.9-mingw/Makefile.am
--- gsl-1.9/Makefile.am	2006-11-02 17:50:01.000000000 +0000
+++ gsl-1.9-mingw/Makefile.am	2007-07-08 00:04:45.000000000 +0100
@@ -21,6 +21,12 @@
 libgsl_la_LDFLAGS = -version-info $(GSL_LT_VERSION)
 noinst_HEADERS = templates_on.h templates_off.h
 
+MINGW32_HOST = @MINGW32_HOST@
+if MINGW32_HOST
+libgsl_la_LIBADD += cblas/libgslcblas.la
+libgsl_la_LDFLAGS += -no-undefined
+endif
+
 m4datadir = $(datadir)/aclocal
 m4data_DATA = gsl.m4
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]