From: Ed <ej...@id...> - 2007-02-07 13:15:38
|
Howdy all! I have a working example of a libtool library that builds and passes tests with MingW. Here are the files, if anyone else wishes to try it. A distribution can be found here: ftp://ftp.unidata.ucar.edu/pub/ed/mindll-1.0.tar.gz There are only 5 files, Makefile.am, configure.ac, mindll.c, mindll.h, and tst_mindll.c, so I've included them all below. I hope this helps anyone out there working with MingW and DLLs! Thanks to the MingW team for a great port to Windows! Ed Makefile.am: # This is the automake file of a minimal DLL for MingW. # Ed Hartnett 2/6/2007 # The library. lib_LTLIBRARIES = libmindll.la # The source code. include_HEADERS = mindll.h libmindll_la_SOURCES = mindll.c # Link options. libmindll_la_LDFLAGS = -version-info 1:0:0 -no-undefined -Wl,--output-def,.libs/libmindll.def # Test program. check_PROGRAMS = tst_mindll TESTS = tst_mindll # Tell the test program to link to mindll library. LDADD = libmindll.la configure.ac: # This is the autoconf file of a minimal DLL for MingW. # Ed Hartnett 2/6/2007 AC_INIT([mindll], [1.0], [goo...@us...ke]) # Find out about the host we're building on. AC_CANONICAL_HOST # Initialize automake with options. AM_INIT_AUTOMAKE([foreign -Wall]) # Get C compiler. AC_PROG_CC AM_PROG_CC_C_O # Produce a windows DLL. This macro must be before AM_PROG_LIBTOOL. AC_LIBTOOL_WIN32_DLL # Initilize libtool. AC_PROG_LIBTOOL # Find the install utility. AC_PROG_INSTALL # Produce the Makefile. AC_CONFIG_FILES([Makefile]) AC_OUTPUT() mindll.c: /* This is the sole function in a minimal MingW DLL. Ed Hartnett, 2/6/2007 */ __declspec(dllexport) int call_me(int i) { return i-5; } mindll.h: /* This is the header file for a minimal MingW DLL. Ed Hartnett, 2/6/2007 */ #ifdef __cplusplus extern "C" { #endif /* This is the sole function of this dll. It returns i - 5. */ __declspec(dllimport) int call_me(int i); #ifdef __cplusplus } #endif tst_mindll.c: #include <mindll.h> #include <stdio.h> int main() { if (call_me(6) != 1) return 1; return 0; } |