Search code examples
makefilecygwinautotools

autotools -- make doesn't create dll under cygwin


I created a simple test application + library that I am building using autotools. The problem is that make doesn't generate a dynamic library (DLL or so) under Cygwin.

Makefile.am:

ACLOCAL_AMFLAGS = -I m4
VERSION=0:0:0
EXTRA_DIST = autogen.sh
bin_PROGRAMS = testApp
libtest_la_SOURCES = src/testLibrary.c
libtest_la_LDFLAGS = -version-info ${VERSION}
testApp_SOURCES = src/testApp.c
testApp_LDADD = libtest.la
lib_LTLIBRARIES = libtest.la

configure.ac:

AC_INIT(foobar, 1.0, [email protected])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_SRCDIR(src)
AC_PROG_CC
AM_PROG_CC_C_O
LT_INIT
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([subdir-objects])
AC_OUTPUT(Makefile)

configure indicates that a dynamic library will be built:

checking whether the gcc linker (/usr/x86_64-pc-cygwin/bin/ld.exe) supports shared libraries... yes
checking whether -lc should be explicitly linked in... yes
checking dynamic linker characteristics... Win32 ld.exe
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking that generated files are newer than configure... done

but no dynamic library is built:

$ ls .libs
libtest.a  libtest.la  libtest.lai  lt-testApp.c  testApp.exe  testApp_ltshwrapper

Solution

  • In Makefile.am, libtest_la_LDFLAGS is missing -no-undefined:

    libtest_la_LDFLAGS = -version-info ${VERSION} -no-undefined