cannot build libtool library from non-libtool objects - any workaround?

159 views Asked by At

I have this code for makefile automake:

noinst_LTLIBRARIES = libwinsane.la
libwinsane_la_SOURCES = init.c
libwinsane_la_CXXFLAGS = -I$(top_srcdir)
libwinsane_la_DEPENDENCIES  = manifest.$(OBJEXT)
libwinsane_la_LIBADD = manifest.$(OBJEXT)
manifest.$(OBJEXT): manifest.rc utf8.xml
    windres -o $@ $(top_builddir)/libwinsane/manifest.rc

it configures with ./configure fine, but in the end, 'make' command results with error:

libtool:   error: cannot build libtool library 'libwinsane.la' from non-libtool objects on this host: manifest.o

But I belive that manifest.o can be totally merged with init.o, I don't understand, why libtool complains about that so hard. Is there any solution?

2

There are 2 answers

0
user2426290 On
noinst_LTLIBRARIES = libwinsane.la
libwinsane_la_SOURCES = init.c
libwinsane_la_CXXFLAGS = -I$(top_srcdir)
libwinsane_la_LIBADD = manifest.lo
libwinsane_la_DEPENDENCIES  = manifest.$(OBJEXT)

manifest.$(OBJEXT): manifest.rc utf8.xml
    libtool --mode=compile windres -o $@ $(top_builddir)/libwinsane/manifest.rc
0
jjorge On

Since libtool is involved, one would use the .lo suffix for consistency. That should help detect double use(*) of a source file.

.rc.${OBJEXT}:
    ${RC} $< $@
.rc.lo:
    libtool --mode=compile --tag=RC ${RC} $< $@

The corresponding main makefile fragment to use it, I would do like so:

lib_LTLIBRARIES = libfoo.la
libfoo_la_SOURCES = manifest.rc
libfoo_la_LIBADD = manifest.lo
manifest.lo: utf8.xml
# Alternatively:
# bin_PROGRAMS = foo
# foo_SOURCES = manifest.rc
# foo_LDADD = manifest.o
# (*) Be wary of the usual "object 'manifest.$(OBJEXT)' created both with libtool and without"

If automake gained a default rule for .rc sources in the future, this seems like a forward-compatible approach, since automake would just add manifest.lo to LIBADD again, which is idempotent.

For defaulting RC, you can add into configure.ac:

LT_PROG_RC