我创建了一个使用autotools构建的简单测试应用程序+库。问题是make不会在Cygwin下生成动态库(DLL左右)。
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, me@mail.com)
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表示将构建动态库:
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
但没有构建动态库:
$ ls .libs
libtest.a libtest.la libtest.lai lt-testApp.c testApp.exe testApp_ltshwrapper
答案 0 :(得分:1)
在Makefile.am中,libtest_la_LDFLAGS
缺少-no-undefined
:
libtest_la_LDFLAGS = -version-info ${VERSION} -no-undefined