简体   繁体   English

无法从非 libtool 对象构建 libtool 库 - 任何解决方法?

[英]cannot build libtool library from non-libtool objects - any workaround?

I have this code for makefile automake:我有 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:它使用 ./configure 进行配置,但最后,“make”命令导致错误:

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.但我相信 manifest.o 可以与 init.o 完全合并,我不明白,为什么 libtool 会如此抱怨。 Is there any solution?有什么解决办法吗?

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

Since libtool is involved, one would use the.lo suffix for consistency.由于涉及 libtool,因此可以使用 .lo 后缀来保持一致性。 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:对应的主要 makefile 片段要使用它,我会这样做:

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.如果 automake 将来为 .rc 源获得了默认规则,这似乎是一种向前兼容的方法,因为 automake 只会将 manifest.lo 再次添加到 LIBADD,这是幂等的。

For defaulting RC, you can add into configure.ac:对于默认 RC,您可以添加到 configure.ac:

LT_PROG_RC

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM