This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
win32 DLL build
- From: Clemens Fruhwirth <clemens at endorphin dot org>
- To: libffi-discuss at sourceware dot org
- Date: Sat, 11 Oct 2008 21:01:27 +0200
- Subject: win32 DLL build
Hi folks,
I'm trying to build libffi as DLL, but I'm not sure if this was meant
to be.
./configure --enable-shared=yes --enable-static=no
(the latter just to make sure)
First, libtool complains that there are undefined symbols when linking
libffi.la, and resorts to linking it static. This is the case
indeed. Changing "allow_undefined_flag" in libtool to something else
than "unsupported" produces a dll. Indeed there is a ffi symbol that's
undefined, which is ffi_prep_args. Its origin is in win32.S, right at
the beginning of the file.
".globl ffi_prep_args"
However, that the only place where this symbol is mentioned in win32.S
so presume it's a leftover from something old. Removing it, or adding
the underscore prefix fixes the problem partially.
Further, the following autoconf/automake hackary is necessary. It's
ugly I know, and even libtool admits it but see libtool comments
around line 1462 (or the search for "libtool link mode")
I haven't tested the resulting dll but it is probably a start.
--- build/Makefile.am 2008-02-21 14:21:24.000000000 +0100
+++ build-shared/Makefile.am 2008-10-11 20:44:15.000000000 +0200
@@ -165,7 +165,7 @@
AM_CFLAGS = -Wall -g -fexceptions
-libffi_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version`
+libffi_la_LDFLAGS = $(LIBFFI_LDFLAGS) -version-info `grep -v '^\#' $(srcdir)/libtool-version`
AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
AM_CCASFLAGS = $(AM_CPPFLAGS)
--- build/configure.ac 2008-02-24 18:20:21.000000000 +0100
+++ build-shared/configure.ac 2008-10-11 20:58:01.000000000 +0200
@@ -26,6 +26,18 @@
AM_PROG_AS
AM_PROG_CC_C_O
+
+AC_LIBTOOL_WIN32_DLL
+
+case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+ if test "$enable_shared" = yes; then
+ LIBFFI_LDFLAGS="-no-undefined -Wl,--export-all-symbols"
+ fi
+ ;;
+esac
+AC_SUBST(LIBFFI_LDFLAGS)
+
AC_PROG_LIBTOOL
AM_MAINTAINER_MODE